In this C tutorial, you will learn to start your IDE to write your first program. Also, you will learn various ways to compile and execute the program in an elegant way.
To start writing your first program in C, you need to start the code block IDE. Follow the below steps for creating a new C file.
In the text editor section, you can create your desired program and then save the program for future use. To save the program you can either use the shortcut keys Ctrl+S or the Save icon in the toolbar.
After program creation, the next important action to be done is the Compilation and Execution of C programs. Compilation simply means checking whether the program created is syntactically correct or not. Execution means running the code to produce an output.
Here we will discuss how Compilation and Execution can be performed using CodeBlock in the Windows environment step by step.
In CodeBlock we have a build icon to compile the programs and a run icon to execute the programs. If we want to compile and run in one go there is another option named build and run icon available at the toolbar. In addition, a rebuilt and abort icon is also available. All these options make the users work hassle-free.
The other way to operate build and run is by going to the menu bar build where all the options and its shortcut keys are available.
After saving the program you have to compile the program using any of the above options, we use Ctrl+F9. All messages after compilation will appear in the Build Log tab of the log Windows underneath the text editor area. You will see something like this:
Here you can see there are no errors but 2 warnings. Errors can be syntactic errors or exceptions which halt the program from the compilation. Once we encounter an error we need to resolve it first to proceed further. While warning tells you the indication that you are doing something wrong and either you can rectify it now or leave it as it is and rectify it later. Warning never halts the compilation.
Now you can run your program which will give you a window as shown below. All your output will be displayed in this window.
Note: Make sure to close this window by pressing any key on the keyboard. Keeping this open disables the build and run activity in the CodeBlock.