"How comes it dont work"
Don't you mean will not compile?
This will compile & run, but you need to add a way to exit the program.
int main() {
int hello = 2;
do {
system("PAUSE");
} while (!hello);
}
M.B.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2007-07-07
You simply placed the closing brace on the wrong side of the while statement; so the while is inside the do-while, not part of it!
Consider using while in preference to do-while, it is less error prone and in this case makes no difference to the functionality. Either way, check teh syntax of do-while you had:
do{... while(condition);}
instead of
do{...}while(condition);
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
include <cstdlib>
include <iostream>
using namespace std;
int main()
{
int hello = 2;
do {
system("PAUSE"); //Only code in do-while loop
while (hello!=1);
}
}
How comes it dont work, thanks!
"How comes it dont work"
Don't you mean will not compile?
This will compile & run, but you need to add a way to exit the program.
int main() {
int hello = 2;
do {
system("PAUSE");
} while (!hello);
}
M.B.
You simply placed the closing brace on the wrong side of the while statement; so the while is inside the do-while, not part of it!
Consider using while in preference to do-while, it is less error prone and in this case makes no difference to the functionality. Either way, check teh syntax of do-while you had:
do{... while(condition);}
instead of
do{...}while(condition);
Clifford