Quantcast
Channel: Active questions tagged return-value - Stack Overflow
Viewing all articles
Browse latest Browse all 210

main function return 1 but debug console prompts program has exited with code 0?

$
0
0

Trying to learn C++ here, I was playing with the main function return value, and when the return value is 1, I still got from the debugging console saying

"The program '/Users/zzli/Documents/GitHub/Codes/C++/HelloWorld' has exited with code 0 (0x00000000)."

Isn't the program should exit with code 1 in this case?

Here is my code:

#include <iostream>using namespace std;int main(){    cout << "Hello World! \n";    int a = 8;    if (a==8)    {       return 1;    }    else     {        return 0;    }}

and here is the debugging console screenshot:enter image description here

I have tried other values as the return value of the main function, however I still get the "exited with code 0" message.


Viewing all articles
Browse latest Browse all 210

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>