Big Tuto: Program with the C language

Chapter 2: Let's install the softwares to program in C!

   

Tutorial presented by: The Ludovyc and Jérémie F. Bellanger (Jay)
Publication: March 1, 2014
Last revision: March 9, 2025

     

   In this chapter we'll start getting down to business, installing all the softwares we'll need to program in C!cool 

   Depending on your experience and your OS (Windows, Mac or Linux), we will offer you 3 different alternatives. Then it's up to you to choose! wink

   These 3 alternatives are as follows:

1. Use the all-in-one IDE (Intelligent Development Environment) Code::Blocks : This is the number 1 choice for beginners because it is relatively easy to learn and allows you to compile/launch the program in 1 click.  wink And it is also compatible with Windows, Linux and Mac. cool

2. Use the all-in-one IDE: Microsoft Visual Studio 2022 (or later):  This IDE is one of the most powerful on the market and offers many advantages that others do not necessarily have, such as an intelligent debugger, or real-time red underlining of programming errors (like Word for spelling)! On the other hand, it will be larger and more complex to configure.wink

   Okay, here we go! smiley

   

   I- Installing Code::Blocks

   

   So we are going to install and configure our IDE: Code::Blocks which will bring together everything we need.

   To do this, go to the following address: http://www.codeblocks.org/downloads/26 and download the version corresponding to your OS.

   - If you are on Windows , you will choose the recommended version: codeblocks-20.03mingw-setup.exe (or later if available) which will include the IDE + the MinGw compiler.

   - If you are on Linux , you can also download the version corresponding to your OS. That said, there is a good chance that it is also already available in one of the repositories, and you will therefore be able to install it more simply using an apt-get, or the software manager (visual or not) integrated into your version of Linux. 

   Once Code::Blocks is installed, launch it! Now let's take a quick tour of the owner! wink

   This is what you should get when you start it. You will notice, in the center of the window, the 2 most useful options, namely: create a new project and open a new one. Also note that the recently opened projects will then appear below, and you will just have to click to open them. Convenient, right? cool

   

   

   Since we are just starting out, let's first create our first project! To do this, click on Create a new project . You will see the following window:

   

   

   There we will choose to create a Console application .

   What?! devilWe're going to program on PS 5? heart I love this console!!! wink

   Uh, no! Let me calm you down right away!  laugh In fact, console mode means the Windows console, you know that black window with white text, without any images, which almost takes us back to the (good) old days of DOS!  wink Console mode is therefore opposed to GUI mode (for Graphical User Interface), with its beautiful windows filled with images. 

   But why make a console app then? laugh It sucks! devil

   Well, quite simply, because creating a window requires more knowledge. If you are new to C, you will therefore prefer to start with the console mode because it is more accessible. Furthermore, for some basic programs, a GUI mode is not essential and would only serve to make it look pretty. We can therefore prefer to program it in console to save time.

   However, rest assured, you will make plenty of GUIs when you later start the Big Tutorials with the SDL (or XNA) and program video games. cool

   Okay, come on, then press GO!

   

   

   Here, just click Next.

    

    

   Here you will choose the C language, because that is the one we will learn and use as well. Later, when you get into C++, you can also use Code::Blocks. wink

    

  

  

   This is where you will enter the name of your new project and choose where to save it on disk. Try to group all of your study projects in the same directory as much as possible to find them more easily.  wink Then click Next.

   

   

   There, don't touch anything and do Finish.

   

   

   Congratulations, you have just created your first project! cool

   You will notice that a main.c file already exists and that it contains the code of a Hello world (= basic program whose purpose is to display Hello World)! This is good, it will allow us to check that it compiles well and that everything works. wink

   

   

   See those little icons at the very top? sad

   I have colored the ones that will be most useful to us. smiley

   In red, you will find in order the icon that will allow us to add a new file to our project (because you will see it later in the Big Tuto, but we will need dozens of files for our larger projects), the icon to open an existing project, and finally the diskettes that will save the current file or all the files at once (more practical so as not to forget any wink).

   In yellow, it's classic: undo/redo, cut/copy/paste and search.

   In green, finally, we find the gear button which will compile our project, the button with the green arrow which will launch our compiled program, the gear button and arrow together which will compile then launch the program and finally the blue circular arrow which will regenerate the project from A to Z (by recompiling everything).

   To test, press the gear button then the green arrow, or the 2 in 1 button (your choice), and you should see the console appear and say "Hello World!" cool

  

  

   Congratulations, you are now ready to write some code, and you can move on to the next chapter (unless you are also interested in the other types of installations wink)!

   

   

   

   II- Installing Visual Studio

   

   To install Visual Studio 2022 or later, go to this address:

https://visualstudio.microsoft.com/fr/ 

Updated March 7, 2025: Since Visual Studio editions follow each other quickly but are quite similar, we do not update this part constantly. The operation remains similar.

Also note that VS Code is available, more versatile and practical. We have written another tutorial to configure it under Python. To add C or C++, just download the corresponding extensions and add a compiler. It is a bit technical but there are plenty of tutorials on this on the web. 😉

   Download the installer, then install Visual Studio 2022 Community (or whatever you want). Then choose what you want to install, selecting at least C/C++. 

   As with Code::Blocks, we'll see together how to create a new project in C (you'll actually have to choose C++, but you can still program in C, C++ being permeable to C functions wink). So choose New Project... under Start, on the left or choose Empty Project from the home page (it's the same thing).

      

   OR

   

   Here, be careful to choose your project in C++, because depending on what you have chosen, VS can also manage other programming languages smiley.

   I'll let you configure the name of your project and the location to save it .

   Then choose add a new item to your solution (you can open it in View / Solution Explorer, if it doesn't appear).

  

   

 

      

   Call it main.c (later we'll do the same with the .h header files):

      

   

   In this new file, enter the following code:

    

#include <stdio.h>
#include <stdlib.h>
 
int main()
{
    printf("Hello world!\n");
    return 0;
}

       

   Then do CTRL+F5 or press the green arrow at the top (Local Windows Debugger) and answer YES, if you are asked to compile the project, to launch it. You will then see your Hello World appear!cool

     

        

  

   And there you have it, you are now ready to program in C with Visual Studio 2022, and you can move on to the next chapter.wink

        See you soon for the next chapter. smiley

 

This site uses cookies to enable you to log in. We do not store or sell any personal data. By continuing to use this website, you agree to their use. Thanks!