How to create and run C program using CodeBlocks

Code::Blocks

Introduction

CodeBlocks is a cross-platform (Linux, Mac, Windows (uses wxWidgets)), open-source, free IDE that supports GCC, Visual C++, and Clang compilers.

CodeBlocks is a powerful IDE for creating, compiling, executing and debugging C/C++ programs.

Please read previous post : How To Install CodeBlocks IDE on Windows

Create C Project In CodeBlocks

  1. Open CodeBlocks, go to Start Menu > All Apps > CodeBlocks > CodeBlocks.
  2. Click on the File menu, select New > Project….
codeblocks project
  1. From the New form template window select “Console application” and click the “Go” button.
codeblocks project
  1. If you see a welcome message, click the “Next >” button to skip the welcome message.
codeblocks project
  1. On the next window, select your language from Console application window and click the “Next >” button.
codeblocks project
  1. On the next window,
    1. Type “Project_1” in the Project title Text Field to change Project Name.
    2. Click the “ellipsis” button present under Folder to create project in. Browse your C workspace, mention the file name click Finish. Navigate to save project directory (ex: D:\Program\Algortihm).
    3. Click the “Next >” button.
codeblocks project
  1. On the next window, click the “Finish” button.
codeblocks project
  1. Now in the left side of the screen go to Projects in the “Management” sub-window. Expand your new project and its folder “Sources“. You will see that CodeBlocks.
codeblocks project

Compile and run C program in CodeBlocks

Once you created your first C Project, You see? The “hello-world” code is already there. It is time to compile and run your first C program.

  1. Go to menu Build > “Build and Run” or just press F9 and then OK, when you are asked if you want to build the project.
codeblocks project
  1. A console will open and you will see the greeting on the screen.
codeblocks project

Thanks for reading!

Leave a Reply

Your email address will not be published. Required fields are marked *