Hello World in C++, the long way

Open Source Your Knowledge, Become a Contributor

Technology knowledge has to be shared and made accessible for free. Join the movement.

Create Content

How programs run

For compiled languages like C and C++, source code like program.c is fed into the compiler which outputs an executable simply called program (or program.exe if on Windows). This program can be run from the command line with ./program. The leading ./ essentially expands to your current directory which under Linux would probably turn into something like /home/name/Documents/my-project/program. After running this, every program returns an exit code. Normally, this is used to indicate whether the program crashed (with anything other than 0 meaning a failure). However, for testing purposed, we can return whatever we would like. To view the exit code, immediately after running a command, type this command. Linux: echo $? Windows: echo %errorlevel%. For instance, try changing directories with cd .. and view the exit code. Now try cd nonexistentDir and you will see a difference.

Open Source Your Knowledge: become a Contributor and help others learn. Create New Content