Learn how to set up C and C++ programming on a Windows Computer

Let me walk you through how to set up C and C++ programming on a Windows computer:

Video Tutorial : Learn how to set up C and C++ programming on a Windows Computer

Download the Compiler

First, you'll need a compiler. We use GCC, which can be downloaded through the MINGW toolset from winlibs.com. Make sure to download the correct version (32-bit or 64-bit) based on your system. It’s recommended to select the version with POSIX threads for better compatibility.

Extract and Set the Path

After downloading, extract the files to the C drive. This will create a folder called MINGW64, which contains all the tools, like GCC, G++, and GDB. Next, you need to update the Path environment variable so that your system can access these tools from any directory. This allows commands like gcc or g++ to work anywhere in the Command Prompt.

Verify the Installation

Once you’ve set the path, open the Command Prompt and run commands like gcc --version or g++ --version. This step verifies that the installation was successful by showing you which version of the compiler is installed.

Install Visual Studio Code (VS Code)

Now, we move on to the editor. Download VS Code from code.visualstudio.com. During installation, make sure to check options like creating a desktop shortcut and adding VS Code to the system Path. This makes it easier to open and use VS Code.

Set Up the Workspace

After installing VS Code, you’ll create a workspace. This is simply a folder where your projects will be stored. Create a folder, such as “C Programming,” on your desktop and save your workspace inside it. Within this workspace, create a project folder (e.g., “Hello”) to hold your code files.

Write Your First Program

Inside the project folder, you can create a basic “Hello, World!” program in C, saving it as hello.c. This program will simply print "Hello, World!" when run.

Install C/C++ Extensions

Before running the program, install the necessary extensions in VS Code. You’ll need the “C/C++” and “C/C++ Extension Pack” by Microsoft. These tools provide code completion, debugging, and other helpful features.

Run Your Program

To run your program, click the Run icon in the top-right corner of VS Code and select the GCC toolchain. After that, your program will run, and you’ll see "Hello, World!" output in the terminal.

Modify the Program for User Input

To make things more interactive, you can modify the program to ask for the user's name and then display a personalized greeting (e.g., "Hello, [Name]"). This involves creating a character array to store the name and using the scanf() function to capture user input.

Customize VS Code Settings

VS Code has several customization options, such as enabling autosave, which automatically saves your changes as you work. This is a useful feature to explore.

Final Notes

If you run into any problems or have questions during this setup process, leave a comment or reach out for help, and we’ll try to assist you.