Thread: do-while loop
View Single Post
Old 06-21-2003, 09:52 AM   #4 (permalink)
ender
Code Monkey
 
ender's Avatar
 
Join Date: Mar 2003
Location: Evansville, IN
Posts: 75
ender is on a distinguished road
Send a message via AIM to ender Send a message via Yahoo to ender
Your problem lies in the fact that your test will only exit if you hit 7 or higher. This is due to the fact that <= says 'while it is less than or equal to 6, it is true." However, as your 'exit' happens ON six, you have to have 6 be an exit condition, so your loop should be something like:
Code:
do {
     // Some code
} while (someVar < 6);
Sorry if this sounds belittling, I didn't mean it to. Hope this helps.

Ted
__________________
while(1) fork();
ender is offline   Reply With Quote