not_l33t
not_l33t

Reputation: 1345

How to create an "Exit program" command

How could I make a line of code that would exit out of my program after input is given by the user for a specific word?

the psuedo-code of what I have is as follows:

take input;

compare (input) to exit word;

if input is same as exit word

exit the program <------- help here;

else

rest of program;

Upvotes: 0

Views: 17643

Answers (3)

jonmorgan
jonmorgan

Reputation: 2610

At the risk of sounding too terse, exit();

Upvotes: 0

Šimon T&#243;th
Šimon T&#243;th

Reputation: 36451

If the code is inside main, you can simply use return if somewhere else use exit

Upvotes: 4

Oliver Charlesworth
Oliver Charlesworth

Reputation: 272802

Use the exit() function.

Upvotes: 0

Related Questions