🔔 Get the scoop first! 📢 Join our Telegram for instant updates! 🚀. Join Channel Join Group!

How to Get Started with C/C++ in Visual Studio Code

Learn how to set up Visual Studio Code for C and C++ programming in this step-by-step guide. Includes instructions on installing the necessary extensi
Please wait 0 seconds...
Scroll Down and click on Go to Link for destination
Congrats! Link is Generated
Visual Studio Code Setup Instruction

Setting up Visual Studio Code (VS Code) for C and C++ programming is a great way to write, compile, and debug your code efficiently on Windows or Mac. This comprehensive guide will walk you through each step, ensuring you have all the tools and extensions needed for a smooth programming experience. Whether you are a beginner or an experienced developer, follow these instructions to get started quickly.

Step 1: Download and Install Visual Studio Code

First, download the latest version of Visual Studio Code from the official website. Choose the correct version for your operating system (Windows, Mac, or Linux), then follow the on-screen instructions to complete the installation.

Download VS Code

For best performance, it is recommended to choose the 64-bit version if your system supports it.

Step 2: Install Essential Extensions in VS Code

After installing VS Code, open the editor. To enable C and C++ programming, you need to install a few important extensions.

Install the C/C++ Extension:

Click the Extensions icon on the left sidebar (it looks like four squares), then search for "C/C++". Install the extension published by Microsoft to enable C and C++ language support.

Extension Icon in VS Code

Once installed, reload VS Code to activate the extension.

Install the Code Runner Extension:

Code Runner allows you to quickly run C/C++ code inside VS Code. Search for "Code Runner" in the Extensions panel and install it.

Code Runner Extension Setting

After installation, go to the "Extension Setting" for Code Runner.

Code Runner Terminal Setting

Scroll down and look for the "Code-runner: Run In Terminal" option, or simply search by

@ext:formulahendry.code-runner
. Make sure this option is enabled (ticked).

Step 3: Install GCC Compiler (MinGW) for Windows

To compile and run C and C++ programs, you need a compiler. GCC (GNU Compiler Collection) is a popular and free compiler. On Windows, you can use MinGW.

Download MinGW and run the installer as Administrator. Follow the installation steps, leaving the default path as C:\MinGW.

Step-1: MinGW Installation Screen

Click the Install button and follow the prompts. Do not change the installation path.

Step-2: MinGW Installation Path

Once installation is complete, select all the packages you need and click Installation > Apply Changes. This may take a few minutes.

Step-4: MinGW Package Installation

Step 4: Set Up Environment Variables

To use the GCC compiler from any directory, you need to add it to your system's PATH environment variable.

Right-click This PC or My Computer, select Properties, then go to Advanced system settings and click Environment Variables. Under "System variables", find and select Path, then click Edit and add C:\MinGW\bin to the list. Click OK to save.

Final Steps: Test Your Setup

Open Visual Studio Code and create a new C or C++ file. Write a simple program and use the Code Runner extension to compile and run it. If everything is set up correctly, you should see the output in the terminal. If you encounter errors, double-check your compiler installation and environment variable settings.

Conclusion

By following these steps, you can set up Visual Studio Code for C and C++ programming on Windows or Mac. This setup gives you a powerful, flexible, and modern development environment. Remember to keep your extensions and compiler updated for the best experience.

For more tips, troubleshooting, and advanced configurations, visit the official VS Code C++ documentation.

A+A-

6 comments

Write your comment below.

Enter the URL of the Image or Code Snippet, or Quote, then click the copy button you want to post. Copy the parsed result and paste it into the comments field.


A perfect massage - feel fantastic. Spamming is strongly prohibited!

  1. ভিডিও টিউটোরিয়াল দিলে আরো সহজে বুঝা যেত। কিন্তু এভাবে করার পরও সেটিং করতে পেরেছি। ধন্যবাদ ❤️️
  2. Thanks! Worked for me
  3. Maraming salamat. Ang tutorial na ito ay mas mahusay kaysa sa isang youtube video tutorial. Talagang madaling maunawaan.
  4. Thanks a lot. It worked for me perfectly.
  5. Great article! 👍 The instructions are clear and easy to follow, making it simple to set up Visual Studio Code for C and C++ programming. The article provides step-by-step guidance on installing the necessary extensions, such as the Microsoft C/C++ extension, for cross-platform development. It also explains how to install a C++ compiler, like MinGW, and configure it properly by adding the compiler to the system path. The article even includes a "Hello World" example to test the setup and provides tutorials for different platforms. Overall, it's a comprehensive guide that covers all the essential steps to get started with C and C++ programming in Visual Studio Code. 🖥️💻
  6. 🤓
Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.
error: Content is protected !!