| Thread Closed |
termination function in C |
Share Thread | Thread Tools |
| Jul26-06, 08:58 PM | #1 |
|
|
termination function in C
Hey,
I was just wondering if there is a simple command in C that terminates the program. So say I am getting input from the user, and if they type '0' I want the program to terminate, I would use this in an if statement to close the program. Thanks! |
| Jul26-06, 09:45 PM | #2 |
|
|
As far as I know, no such function exists, at least not in stdio.h. You can still pretty easily check if input is "0." If you're getting a char, see if "the_gotten_char=getchar() == '0'". If you're reading a string, see if "atoi(input_string) == 0".
If you mean to just press the 0 button (not input "0"), then I don't know... |
| Jul26-06, 09:46 PM | #3 |
|
|
|
| Jul26-06, 10:53 PM | #4 |
|
|
termination function in C
exit(1)...but you could always do
main.... { while (true) { if(key==0) break; } } |
| Jul27-06, 07:53 AM | #5 |
|
|
exit(1) or assert (for assert #include <assert.h>) should do the trick
|
| Jul27-06, 05:39 PM | #6 |
|
|
thx everyone!
|
| Thread Closed |
| Thread Tools | |
Similar Threads for: termination function in C
|
||||
| Thread | Forum | Replies | ||
| Transmission line termination? | Electrical Engineering | 11 | ||
| [SOLVED] Dirac delta function and Heaviside step function | Advanced Physics Homework | 2 | ||
| [SOLVED] fourier transform of a function such that it gives a delta function. | Calculus & Beyond Homework | 1 | ||
| Histamine non-termination | Biology | 0 | ||
| Polymerization Termination | Biology, Chemistry & Other Homework | 0 | ||