I compiled two simple programs in C ++, using minor changes in each of them, and used the query echo $?to output the value returned by the OS by default.
Program 1
int main()
{
return 0 ;
}
Program 2
int main()
{
return -1 ;
}
When I launched the first program and did echo $?, the value was as expected 0, but when I launched the second program and did echo $?, the value was 255 instead of the expected -1.
Why is this so?
I use Ubuntu 12.04 LTS in case it matters
source
share