Where does the int returned from main() go?
This depends upon your platform. And exactly what gets passed back to your environment/operating system/etc. is implementation-defined. As mentioned above, startup code written by your compiler vendor calls your main, and similarly, termination code terminates your program. An implementation-defined description follows. On UNIX, the low-order 8-bits of the int status are returned. Another process doing a wait() system call, which is not a Standard function, might be able to pick up the status. A UNIX Bourne shell script might pick it up via the shell’s $? environment variable. MS-DOS and MS-Windows are similar, where the respective compilers also have functions such as wait upon which another application can obtain the status. As well, in command line batch .BAT files, you can code something like IF ERRORLEVEL…, or with some versions of Windows, the %ERRORLEVEL% environment variable. Based upon the value, the program checking it may take some action. Do note as mentioned above, that