When I try to compile my code, it says "do statement must have while in function main()
". I do have while. What is wrong?
Printable View
When I try to compile my code, it says "do statement must have while in function main()
". I do have while. What is wrong?
while your at it don't forget to you know, show us the code....
just in case u didn't know:
do
{
program junk
}
while(some condition)
/* edit: Dammit i hate same-second posts....*/
post the code of the loop
Here it is:
Code://before I include all the stuff and declare integers
do
{
//my code
}
while (foe_health>0 && health>0);
This should work just fine
[edit]
Post more of your code
try putting the parentheses against the while not this far away, just a guess.
SHOULD work tho.
Doesn't matter
You are forgetting the error, do statement must have while in function main()
post the whole main
As i said, post more code, like where its standing in your
source
^ you reached 1400, nice job
heh, i stopped paying attention to my PC a long time ago...
*waits for code so he and others can post at the same time some more*
Okay, but it is out of order.
Code:#include <windows.h>//1
#include <conio.h> //2
#include <stdlib.h>//3
#include <iostream.h>//4
int main() //5
{//6
int health;//7
int foe_health;//8
int damage;//9
int foe_damage;//10
int attack;//11
int l;//12
cout<<"How much health should you and the opponent have? ";//13
cin>>health;//14
foe_health=health;//14
cout<<"\nThe fight begins!\n";//15
do//16
{ //16
{//17
randomize();//18
cout<<"Press 1 for punch, 2 for kick, 3 for blast, and 4 for defend.\n";//19
cin>>attack;//20
if (attack==1)//21
{//22
damage=rand () % 6;//23
foe_damage=rand () % 7;//24
cout<<"You punched and did "<<damage<<" damage and the opponent did "<<foe_damage<<" damage.";//25
foe_health-=damage;//26
health-=foe_damage;//27
}//28
if (attack==2)//29
{//30
damage=rand () % 11;//31
foe_damage=rand () % 13;//32
cout<<"You kicked and did "<<damage<<" damage and the opponent did "<<foe_damage<<" damage.";//33
foe_health-=damage;//34
health-=foe_damage;//35
}//36
if (attack==3)//37
{//38
damage=rand () % 20;//39
foe_damage=rand () % 23;//40
cout<<"You blasted and did "<<damage<<" damage and the opponent did "<<foe_damage<<" damage.";//41
foe_health-=damage;//42
health-=foe_damage;//43
}//44
if (attack==42)//45
{//46
damage=foe_health;//47
cout<<"You found the destroy move. To do it again, enter 4 at the attack screen. You did "<<foe_health<<" damage\n";//48
foe_health-=damage;//49
health-=foe_damage;//50
}//51
{//52
if (attack==4)//53
{//54
damage=rand () %20;//55
foe_damage-=damage;//56
health-=foe_damage;//57
}//58
clrscr();//59
//60
cout<<"Your Health: "<<health<<"\nEnemy Health: "<<foe_health<<"\n";//61
}//62
}//63
while (health>0 && foe_health>0);//64
if (foe_health<1)//65
//66
{//67
cout<<"YOU WIN";//68
getch();//69
}//70
//71
if (health<1)//72
//73
{//74
cout<<"YOU LOSE ";//75
getch();//76
}//77
//78
}//79
return 0;//80
}//81
i think u may have
do
{
{ as opposed to
do
{
but i may be wrong, hard to read that.
That's the worst code EVER posted
[edit]
You're using 1 { too much at the beginning and 1 } to much at
the end