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;
If the code is inside main, you can simply use return
if somewhere else use exit
Use the exit()
function.
At the risk of sounding too terse, exit();
精彩评论