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