How to Use Code::Blocks to Create a Simple C++ Program


When you start Code::Blocks, the IDE should look like this -

start 1

Click on the File menu, then New, and Empty file

start2


You can now type in the program text




You should save your file - File menu -> Save file as...




Make sure you save it in a location where you can find it again.  Do not use the Windows directories.  Use the filename extension .cpp  Click on Save



Notice that after you save the file with the .cpp extension, the colors change for keywords.

Now it's time to compile.  Click on the  button.



You should see compile messages in the Build log window below.  Hopefully, you'll see 0 errors and 0 warnings.



Now you can run it.  Click on the run button ().

Your output should appear in the Output window like this ...



That's it!