|
![]() |
Overclock.net - Overclocking.net > Software, Programming and Coding > Coding and Programming > Application Programming | |
C++ restart program help! :)
|
||
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) | |||||||||||||
|
AMD Overclocker
|
Hey guys. I made a currency converter program and I was wondering what function I use to make it restart? I have it so that it asks if you want to quit or not, and if the person answers with either 'y' or 'yes', it will quit, but now I need the function so that it will restart if they enter 'n' or 'no'!
Thanks for the help, guys! Elliott
__________________
Volkswagen Enthusiasts of OCN Aumotocnic "An unfortunate member of the overclock.net insomnia club" Quebec Overclockers - 8019 in 3dMark06s939 Manny 4600+ @ 2809Mhz @ 1.425V (9 hours Orthos blend test stable - 24/7 Usage) - http://valid.x86-secret.com/show_oc.php?id=289741 @ 2945Mhz @ 1.45V - http://valid.x86-secret.com/show_oc.php?id=276669
|
|||||||||||||
|
|
|
|
#2 (permalink) | |||||||||||||
|
Multi-Quote King
|
Um... I'm not that good at C programming (I'm just learning C), but my book had an example where you would have a "while" loop statement, and it would ask you to enter a number to proceed with the equation it solves, or press 0 to quit. So maybe you can use a "while" loop and have someone press "0" if they want to quit, or anything else to proceed.
Just an idea. I'm not especially good at this.
__________________
"But you would be amazed by how many people think that the only reason to have a computer is to play games, and that playing games is all that anyone with a computer does." - dangerousHobo "Linux is everywhere, it is all around us, even now in this very room. You can see it when you look out your window, or you turn on your television. You can feel it when you go to work, when you go to church, when you pay your taxes. " - mbp"I have used a mac before. And they still don't have right click I mean come on." - aakar Blah, blah, can't hear you
|
|||||||||||||
|
|
|
|
#3 (permalink) | |||||||||||||
|
Off By 340 Undecillion
|
Use a do while loop that encases most of the program.
__________________
Congratulations! You have found the secret text! You get a cookie.
|
|||||||||||||
|
|
|
|
#4 (permalink) | ||||||||||||||
|
Linux Lobbyist
|
yeah, do a while statement that re-runs the program until the user answers no
while (userInput != y || userInput != Yes) { ::call initial function:: }
__________________
Quote:
(450x8) (417x9) (425x9)![]()
|
||||||||||||||
|
|
|
|
#5 (permalink) | ||||||||||||||
|
AMD Overclocker
|
Quote:
What do you mean? :S
__________________
Volkswagen Enthusiasts of OCN Aumotocnic "An unfortunate member of the overclock.net insomnia club" Quebec Overclockers - 8019 in 3dMark06s939 Manny 4600+ @ 2809Mhz @ 1.425V (9 hours Orthos blend test stable - 24/7 Usage) - http://valid.x86-secret.com/show_oc.php?id=289741 @ 2945Mhz @ 1.45V - http://valid.x86-secret.com/show_oc.php?id=276669
|
||||||||||||||
|
|
|
|
#6 (permalink) | ||||||||||||||
|
Linux Lobbyist
|
he's saying that you start the while statement in your main function, so that while userInput != y || userInput != yes, the program will continue executing until kingdom come
*edit* do you have your source?
__________________
Quote:
(450x8) (417x9) (425x9)![]()
|
||||||||||||||
|
|
|
|
#7 (permalink) | ||||||||||||||
|
AMD Overclocker
|
Quote:
Lol thanks anyways guys.
__________________
Volkswagen Enthusiasts of OCN Aumotocnic "An unfortunate member of the overclock.net insomnia club" Quebec Overclockers - 8019 in 3dMark06s939 Manny 4600+ @ 2809Mhz @ 1.425V (9 hours Orthos blend test stable - 24/7 Usage) - http://valid.x86-secret.com/show_oc.php?id=289741 @ 2945Mhz @ 1.45V - http://valid.x86-secret.com/show_oc.php?id=276669
|
||||||||||||||
|
|
|
|
#8 (permalink) | |||||||||||||
|
Off By 340 Undecillion
|
int main();
{ //declare variables //welcome message & other things you don't want repeated do { //program that you want repeated . . . . . //ask if you want to repeat and store the answer in, oh lets say 'ans' } while(ans == y || ans == yes) //all closing things return 0; } Hopefully that helps. Ask more if you need it ![]()
__________________
Congratulations! You have found the secret text! You get a cookie.
|
|||||||||||||
|
|
|
|
#9 (permalink) | ||||||||||||||
|
Linux Lobbyist
|
hah! +rep for spending time on something silly like that, we all do it [not for teh lulz]!
__________________
Quote:
(450x8) (417x9) (425x9)![]()
|
||||||||||||||
|
|
|
|
#10 (permalink) | |||||||||||||
|
Every base is base 10
|
I would suggest what bartender posted rather than calling main again. Your way recursively calls main, which wastes memory. The program is trivial so it doesn't really matter, but bartender's post is better coding practice
|
|||||||||||||
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
|
|