How do I make a C++ console program exit?

前端 未结 13 2439
执笔经年
执笔经年 2020-12-03 16:43

Is there a line of code that will terminate the program?

Something like python\'s sys.exit()?

13条回答
  •  借酒劲吻你
    2020-12-03 17:24

    if you are in the main you can do:

    return 0;  
    

    or

    exit(exit_code);
    

    The exit code depends of the semantic of your code. 1 is error 0 e a normal exit.

    In some other function of your program:

    exit(exit_code)  
    

    will exit the program.

提交回复
热议问题