Course content
Chapter 1: Getting started with the C Language
Presentation of the C language and its role in embedded systems. Understand the importance of programming in the field of embedded systems. Overview of basic programming concepts.
0/6
Chapter 2: Exploring Variables and Operators
Discovery of variables: types, declaration, assignment Play with arithmetic operators through exercises
0/3
Chapter 3: Making Decisions with Conditional Statements
Introduction to Conditional Statements with Real-World Examples
0/1
Foundations of the C Language: First Steps in Programming (course 1)
About the lesson

Alright, let's get started! You have your VS Code text editor ready and your GCC compiler installed. Together, these two are like a dynamic duo, ready to achieve great things!

Step 1: Launching VS Code 🚀

If VS Code is already open, close it. Relaunch it so that it takes into account the new compiler that you have just installed.

Step 2: Creating a New File 📝

  1. In VS Code, in the upper left corner, click File and New File. You will see a new blank white window open, ready for your great ideas.
  2. Now click on File again, then Save As.
  3. In the window that opens, choose where you want to save your file.
  4. Name your file premier_programme.c and make sure to give it the extension .c. Press on Save.

Step 3: Write the code 💻

Type the following code into your freshly created file:

#include <stdio.h>

int main() { printf("Hello, World!n"); return 0; }

Step 4: Compiling 🎩✨

Open VS Code's built-in terminal (go to View > Terminal or use the shortcut Ctrl+`). In this terminal, type the following command:

gcc premier_programme.c -o mon_programme

Step 5: Launching the program 🚀
Type in the terminal:

./my program

You should see the message “Hello, World!” – there you go, you have sent your very first message to the world of C programming!

And now, let's decipher it together:

  • #include <stdio.h> : This is an instruction for the compiler. She tells him to include a file called stdio.h, which contains the functions necessary for display.
  • int main() { … }: This is the heart of your program. All C programs start with a main function. This is where it all begins and ends. int indicates that this function will return an integer. Here it returns 0 when the program terminates successfully.
  • printf(“Hello, World!n”); : printf is a function that prints text on the screen. “Hello, World!n” is the text that will be displayed, and n is a special character that creates a new line.
  • return 0; : This indicates the end of the main function and that the program has completed successfully.

🔍 Little note on braces { ... } : They indicate where the content of the function begins and ends main. Everything inside is what the program does.

In summary : You've written a piece of code that tells the computer to display "Hello, World!" on the screen, and it completes successfully. Congratulations, that's your first step into the world of C programming!

Ready for what’s next? Let's go!

Participate in the discussion
Add to favourites