开发者

How to create an "Exit program" command

开发者 https://www.devze.com 2023-01-26 00:20 出处:网络
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?

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();

0

精彩评论

暂无评论...
验证码 换一张
取 消