DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workkloads.

Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Day in the Life of a Developer With Google's Gemini Code Assist: Part 2
  • Next.js vs. Express.js: What Are the Differences?
  • Choosing the Right Functions in C Programming: Strcpy vs. Strncpy
  • From Low Code to No Code: Borne to the Extreme Necessity to Solve Key Tech

Trending

  • While Performing Dependency Selection, I Avoid the Loss Of Sleep From Node.js Libraries' Dangers
  • Beyond ChatGPT, AI Reasoning 2.0: Engineering AI Models With Human-Like Reasoning
  • Internal Developer Portals: Modern DevOps's Missing Piece
  • Unlocking the Potential of Apache Iceberg: A Comprehensive Analysis
  1. DZone
  2. Coding
  3. Tools
  4. C/C++ Dev Environment Using VS Code

C/C++ Dev Environment Using VS Code

VS Code is polyglot. This post will show how to setup VS code for C/C++ development.

By 
Jawad Hasan Shani user avatar
Jawad Hasan Shani
DZone Core CORE ·
Jun. 18, 20 · Tutorial
Likes (2)
Comment
Save
Tweet
Share
9.5K Views

Join the DZone community and get the full member experience.

Join For Free

One Ring to rule them all,
One Ring to find them,
One Ring to bring them all
and in the darkness bind them.

― J.R.R. Tolkien, The Fellowship of the Ring

Whether you are a Lord of the Rings movie fan or not, you will agree that uniformity appeals to almost every one, and having a unified development experience is something developers strive and welcome all the time. 

For a long time, development environment(s) have been tightly coupled with a particular technology e.g. Visual Studio for a mostly .NET-based development. We have seen heated debates among developers where they endlessly argue about one tool over another. This will never end, and it shouldn’t because many times these arguments results in awesome tooling, which we are using today.

In this post, I will share with you a simple C/C++ development environment setup using VS Code. If you are already using VS Code with some other programming language, then you are already half-way there. For others, they can check how the setup looks like and if they might wanna give it a try.

VS Code is a light-weight, open-source, free, and extensible IDE, and it is getting better every day. I use it frequently for my Node.js development work, and in this post I will show you how easy it is start with C/C++ development using same IDE and have the similar experience.

Steps

  • Install Visual Studio Code (Typical Installation, download installer from this link).
  • Download and setup MinGW.
  • VS Code C/C++ extensions setup.

MinGW Setup

MinGW is a native Windows port of the GNU Compiler Collection (GCC), with freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All of MinGW’s software will execute on the 64bit Windows platforms.

You can download MinGW installer from this link. Once downloaded you can double-click to start setup wizard. Also make sure that you are connected to internet.

MinGW installer

You will be also asked to select the package. I selected the mingw g++ as follows. After selection from the menu, click Apply. 

Selecting correct version

Once installation is done, you will find a folder on your C: drive name MinGW. There is a bin folder inside that, and we need to include path to that bin folder to environment variable, so that later it can be found by VS code. 

Edit environment variable

VS Code C/C++ Extensions Setup

From visual studio extensions tab, search for C/C++ extension and install it as follows:

C/++ extension

Another handy extension, you wanna install is Code Runner. This extension will make it very easy for you to run your code. 

Adding Code Runner extension

After installing both extension, restart your VS-Code and we are all ready to write some C/C++.

Coding Part

Although this post is not about C/C++ programming itself, but here are few simple programs written in C and C++ to verify the code execution.

Hello, world C program

C code sample


C++ Code sample
You can click Play button (right-side) on your VS-Code editor (thanks to code runner extension) and check the following results. 

Program execution

Temperature Conversion example code and its output.

Temperatur conversion script

Summary

VS Code can be used with various programming languages. I found using VS code very convenient for C/C++ development as well. Its not the only choice though but it is an easy one to setup and start with. Now, we have setup the tooling, we are ready to write some cool code and I will write some more posts about C/C++ programming in next posts. Till next time, Happy Coding.

Other Links

  • https://code.visualstudio.com/docs/languages/cpp
  • sourceforge.net/projects/mingw/ (minGW installer)
  • https://www.youtube.com/watch?v=Ubfgi4NoTPk
Virtual screening Visual Studio Code dev

Published at DZone with permission of Jawad Hasan Shani. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Day in the Life of a Developer With Google's Gemini Code Assist: Part 2
  • Next.js vs. Express.js: What Are the Differences?
  • Choosing the Right Functions in C Programming: Strcpy vs. Strncpy
  • From Low Code to No Code: Borne to the Extreme Necessity to Solve Key Tech

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!