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!
PhysOrg.com
PhysOrg
science news on PhysOrg.com

>> Ants and carnivorous plants conspire for mutualistic feeding
>> Forecast for Titan: Wild weather could be ahead
>> Researchers stitch defects into the world's thinnest semiconductor
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
 
Recognitions:
Gold Membership Gold Member
Science Advisor Science Advisor
Retired Staff Staff Emeritus
http://www.cplusplus.com/ref/cstdlib/exit.html

- Warren
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