does an infinite loop suck up computing cycles, thus slow
down program?
thnx in advance.
simplified code:
......
.....
for(;{
do{
............
.............
.............
}while(........)
does an infinite loop suck up computing cycles, thus slow
down program?
thnx in advance.
simplified code:
......
.....
for(;{
do{
............
.............
.............
}while(........)
this is what i ment ...
for(;;)
do{
.
.
.
.
}while(...)
its alive... its ALIVE... ITS...AL...IIIVE !!!!!!!!!
If you make a mistake in your post, use the edit button, not reply.
>does an infinite loop suck up computing cycles,
Depends whats going on inside your infinite loop.
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
>> Depends whats going on inside your infinite loop.
how about this?Code:while(TRUE) { malloc(10000); }
its just to repeat a menu.
example:
code:
___________________________________________
for(;;){
do{
cout << "Help on:\n";
cout << " 1. if\n";
cout << " 2. switch\n";
cout << " 3. for\n";
cout << " 4. while\n";
cout << " 5. do-while\n";
cout << " 6. break\n";
cout << " 7. continue\n";
cout << " 8. goto\n";
cout << "Choose one (q to quit): ";
cin >> choice;
}while(choice < '1' || choice > '8' && choice != 'q');
if(choice == 'q') break;
_____________________________________________
its alive... its ALIVE... ITS...AL...IIIVE !!!!!!!!!
@Spectrum48k: Your program is going to spend most of its time waiting for the user to input something, which won't hog the CPU.
@ face_master: Err... yeah... let me try that one
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
@hammer: why is this code amusing ?
Code:while(TRUE) { malloc(10000); }
its alive... its ALIVE... ITS...AL...IIIVE !!!!!!!!!
Lookup the malloc() function in your manual
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
it allocates memory continusly untill i get:
"system low on virtual memory"
now i know.. sometimes i just ask, even though the books are next to me.. sorry bout that ..
its alive... its ALIVE... ITS...AL...IIIVE !!!!!!!!!
Why do you need a forever loop there? Why not just loopOriginally posted by Spectrum48k
its just to repeat a menu.
example:
code:
___________________________________________
_____________________________________________Code:for(;;){ do{ cout << "Help on:\n"; cout << " 1. if\n"; cout << " 2. switch\n"; cout << " 3. for\n"; cout << " 4. while\n"; cout << " 5. do-while\n"; cout << " 6. break\n"; cout << " 7. continue\n"; cout << " 8. goto\n"; cout << "Choose one (q to quit): "; cin >> choice; }while(choice < '1' || choice > '8' && choice != 'q'); if(choice == 'q') break;
?Code:while(choice != 'q')
Oh, and use code tags.
FAQ
"The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.
"If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.