restart the program
like exit the program and it re-execute it or...just go back to the beginning of the code?
nextus, the samurai warrior
restart as in?.....
You design your code well, so you don't need to restart. This is rather vague, to match your question
Or you could get it to spawn a new copy itself.
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
Code:while(something) { YourCode(); }
MagosX.com
Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.
I want the program to restart once it reaches the end. Like a calculator.
> restart once it reaches the end.
You want it to restart every time?
Code:while(1) { stuff }
-Govtcheez
[email protected]
The topic you need to study is called "loops". There are for-loops, while-loops, do-while loops... So, you can also look-up "for", "do", and "while".
[EDIT]
LOOPING and CONDITIONAL EXECUTION/ CONDITIOAL BRANCHING are the two features that make programming valuable. (IMHO)
Last edited by DougDbug; 03-20-2003 at 11:39 AM.
Here is an example of loop I used on a console program I made a while ago.
Thise is not the full code but I think its a good example on how you could do it for a calculator..Code:int main() { program(); return 0; } void program() { while (y != 'e') { menu(); cin >> y; ans(y); } } void menu() // display menu { cout <<endl<< "What would you like to do?" << '\n'<<endl; cout << "[I] Input a date?" << endl; cout << "[O] Output a date?" << endl; cout << "[D] Delete a date?" << endl; cout << "[E] Exit?" << endl << endl; } void ans(char y) // handles answers to menu { switch (y) { case 'i': input(); break; case 'o' : output(); break; case 'd' : delet(); break; case 'e' : break; } }
Luigi
// I use Xcode 1.1 && CodeWarrior 8.3
// When on Mac Os X 10.3.2
// I use Microsoft Visual C++ 6.0
// When on windows XP
i'm going to get really yelled at for this
void main() {
10 //beinging
//end
goto 10;
}
muhahaha
It physically hurts me.
If you ever need a hug, just ask.
>i'm going to get really yelled at for this
So why did you suggest it? void main is very wrong and there are more elegant solutions than goto in this situation.
-Prelude
My best code is written with the delete key.