C++: How can I return a negative value in main.cpp

前端 未结 3 1740
鱼传尺愫
鱼传尺愫 2020-12-30 00:29

As an assignment in school, we have to write a C++ program and returns different error codes in the main.

The problem is that we have to return -2

3条回答
  •  时光取名叫无心
    2020-12-30 01:29

    From C++11 standard 18.5/8:

    If status is zero or EXIT_SUCCESS, an implementation-defined form of the status successful termination is returned. If status is EXIT_FAILURE, an implementation-defined form of the status unsuccessful termination is returned. Otherwise the status returned is implementation-defined.

    Thus is it completely compliant that you get different results for different platforms, and/or compilers.

提交回复
热议问题