Is there an upper limit to the return code of C++ – int main?

Is there an upper limit to the return code of C++ – int main? … here is a solution to the problem.

Is there an upper limit to the return code of C++ – int main?

I’ve been working on the return code today, for which I created a for loop in bash to test it :

for RC in {1..300}
do
    echo "int main(void) { return $RC; }" > test.cpp
    g++ test.cpp -o test
    ./test
    echo $?
done

However, after reaching 255, it seems to start at 0 again. Why is that?

Such as:

252
253
254
255
0
1

Related Problems and Solutions