Why does the program return with an exit code different from the specified?

This is a simple program:

int main() {
    return 0;
}

Exit code 0.

If I write:

int main() {
    return 700;
}

Exit code 188.

Why is there an exit code 188instead 700?

+4
source share
1 answer

While the main function in C returns operating systems int, it is not necessary to use it intas an error code .

700in binary format 1010111100.
Truncating this value to eight bits gives 10111100.
It is equal 188in decimal form.

This means that your OS uses eight bits for error codes. 1


1 , 8 th ( 0, ) 0. - , 9 2, .

+9

Source: https://habr.com/ru/post/1618737/


All Articles