How To Create C/C++ Code In Visual Studio Code

 I like Visual studio code, it’s cross-platformed, and very fast IDE(or for some people they just call it a text editor). But this text editor is very smart and supports many features, well actually you can just create your own extensions if you think that your programming language or tool is not available in the extension market.

In this tutorial I am using Windows, to develop C/C++ code, firstable you need to already have C/C++ build tools, which you can install through Visual studio installer. But if you prefer using MinGW or Cygwin, it’s up to you, but i am not familiar with that.


1. Assuming you don’t have C++ build tools on your windows machine, then first you need to Download Build Tools for Visual Studio 2019 here: https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2019

2. Open Visual studio installer 2019, select Desktop development with C++, and install them.


3. All those above steps are just one time process, you're not gonna repeat that each time you create a new project, just follow this step forward for a new project.
4. Now create new empty folder for your project, and open that folder from your VS code
5. Install this two extension: C/C++ and Cmake Tools by Microsoft


6. Open command palette (Ctrl+Shift+P)
7. Search and execute cmake configure
8. Select one of the Visual Studio Community 2019 Release, for this project i pick amd64


9. Then CMakeListst.txt was not found, just click “Create” button


10. Enter the name of your project, eg: my-project
11. Select project type: Executable
12. Then the tool will automatically create main.cpp and CMakeListst.txt
13. CMake tool would like to configure intellisense, select Allow
14. At this point you already successfully create a C++ project
15. Now you can modify c++ code inside main.cpp whatever you want
16. To build the project
- Either Ctrl + Shift + P > search cmake build
- Or simply press F7
17. To run or debug your code, either:
- Click on the run icon (triangle icon), at the bottom of VScode

- Or Ctrl + Shift + P > search cmake run without debugging
- Or simply press shift + F5

That’s all, you can do many other things using those Cmake plugins, just Ctrl+shift+p and start one of the available Cmake  tools.

Visual Studio Code is one of very popular useful free IDE products, it literally can do anything with the right plugin. This is the IDE that I use if I want to do very fast coding without thinking. I think the only lack of VS code is the refactoring part. For that kind of job, it needs enterprise level IDE i guess.

Popular posts from this blog

ERROR 1348 Column Password Is Not Updatable When Updating MySQL Root Password

How To Create Spring Boot Project Using Netbeans

Spring Kafka - how to use ReplyingKafkaTemplate send and reply synchronously

Upload and Download Rest API using Spring Boot Reactive WebFlux

MIME Types - Complete List