![]() |
|
#1
|
|||
|
|||
C switch / loop question -- Was: Me again.I've got the memory allocation i think, now its down to what should be the simple stuff. I think I've been on it too long and all it needs is new eyes.
the menu (switch clause) should loop forever till i choose the option to quit. but its not, i can choose a function once and it will go back to the menu clause, but if i enter a second function it then decides it wants to close. I cant see why, mucho frustrating. Any help would be appreciated as always, and hopefully one day i'll be answering the questions. Mitch Last edited by JdS : 21-Feb-2004 at 09:50.
Reason: Please use a better title in your thread
|
|
#2
|
||||
|
||||
|
Hi Mitch. I am not 100% sure, why your switch doesn't loop forever. There are no break statements in it. Without a break statement, your code will continue until it hits a break. There should be a break after each one of your case statements.
CPP / C++ / C Code:
I think also, you want to initilize your exit variable to 0 and set it to 1 when on case 5 unless I am missing something. Also about your free problem. Another solution is to NULL point your pointer when your program begins. CPP / C++ / C Code:
That way if free is called it will not do anything. HTH d |
|
#3
|
|||
|
|||
Handy.Quote:
Thats a trick i never knew. Thanks a lot, that will help bundles. And as for the exiting the menu, i've no idea either. I'll keep on it though. Cheers, and hopefully wont be keeping on bothering you Toodle Mitch |
|
#4
|
||||
|
||||
|
First off, indent your do loop and switch
Code:
case 5: exit=1; break; and add a break; at the end of each case |
|
#5
|
|||
|
|||
|
cheers, though i realised my silly error as soon as i'd actually posted it.
This is giving me so much hassle its unreal. Silly mistakes like forgetting &'s. and making the exit value the opposite of what it should be. I've been doing this from 4 till half eight, just got home from work and will now be doing it till heaven knows when. Thanks for all your help, i've got the subtract one sorted, now all i need is the multiply funtion and we're away! Sleep well, Mitch |
Recent GIDBlog
US Elections and the ?Voter?s Responsibility? by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The