questo è il mio banalissimo programma
//fight game
#include <iostream.h>
#include <iomanip.h>
#include <conio.h>
#include <stdlib.h>
#include <time.h>
//begin
int main()
{
srand (time (0) );
int i , d ,v , life , life1 ,c; // dichiarazione variabili
enum Status { CONTINUA , LASCIA};
Status gamestatus;
cout << "schiaccia un tasto per iniziare" << endl;
life = 100; // inizializzazione delle variabili
life1 = 100;
gamestatus = CONTINUA;
while (gamestatus == CONTINUA){ // ciclo del gioco
while ( life > 0 || life1 > 0) //ciclo della vita
{
for (c = 1 ; c <= 4 ; c++) //ciclo del combattimento
{
cout << "hai un nemico davanti a te!" << endl;
cout << "schiaccia un numero" << endl;
cin >> i;
v= i + rand()%9;
d= i + rand()%9;
if (d > 0)
{ if (i > v)
{cout <<"vita " << life -= 10<< "vita avversario " << life1 << endl;
else cout <<"vita " << life << "vita avversario " << life1 -= 10 << endl;
}
else { if (i < v) cout <<"vita " << life << "vita avversario " << life1 -= 10 << endl;
else cout <<"vita " << life -= 10 << "vita avversario " << life1 << endl;
}
}
}
if (life > 0) cout << "hai vinto!" << endl;
else cout <<"hai perso!" << endl;
cout << "vuoi giocare ancora? (CONTINUA/LASCIA)" << endl; //conclusione ciclo di gioco
cin >> gamestatus;
}
getch();
}
e questi sono gli errori che non rieco bene a capire:
(40) : error C2297: '<<' : illegal, right operand has type 'char [17]'
(41) : error C2181: illegal else without matching if
(41) : error C2297: '<<' : illegal, right operand has type 'class ostream &(__cdecl *)(class ostream &)'
(43) : error C2297: '<<' : illegal, right operand has type 'class ostream &(__cdecl *)(class ostream &)'
(44) : error C2297: '<<' : illegal, right operand has type 'char [17]'
(55) : error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'enum main::Status' (or there is no acceptable conversion)
(63) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
cosa devo correggere???
grazie
ciao