|
-
December 6th, 2010, 09:27 AM
#4
Re: a few questions
 Originally Posted by GCDEF
You're right, but stylistically, I'd use a bool. Don't forget to initialize it, and watch the and/or logic there. ...
I nomally don't use a variable in the while condition but use an infinite loop and break the loop when the error condition occurs:
Code:
int main()
{
while (true)
{
...
if (input == 'q') // break the loop when the user types q for quit.
break;
}
return 0;
}
Though the above seems to be more dangerous it actually is less error-prone cause the break would work immediately while the check on 'end' variable works at begin of next loop cycle.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|