How to compile C/C++ program in VS Code

For Windows:
  1. Install MinGW or Dev C++
  2. Open Environment Variables
  3. In System Variable select Path -> Edit -> New
  4. Copy this C:\Program Files (x86)\Dev-Cpp\MinGW64\bin to the New window. (If you have MinGW installed copy its /bin path).
  5. To check if you have added it successfully: Open CMD -> Type "gcc" and it should return: gcc: fatal error: no input files compilation terminated.
  6. Install C/C++ for Visual Studio Code && C/C++ Compile Run || Code Runner
  7. If you installed only C/C++ Compile Run extension you can compile your program using F6/F7
  8. If you installed the second extension you can compile your program using the "play" button in the top bar.


COMMENTS

BLOGGER: 10
  1. Hello, thank you.
    I installed all but i have problem to run and cmd or output panel. idon't anything show me.

    ReplyDelete
  2. I did exactly what was said and I still get the same error as GCC is not recognized as a ninternal or external command operable program or batch file.

    ReplyDelete
    Replies
    1. Check if you added spaces in your file name. and if you have remove the spaces.

      Delete
  3. PS D:\New folder 5\instructor and operator> cd "d:\New folder 5\instructor and operator\" ; if ($?) { gcc for lopp.c -o for lopp } ; if ($?) { .\for lopp }
    gcc.exe: error: for: No such file or directory
    gcc.exe: error: lopp.c: No such file or directory
    gcc.exe: error: lopp: No such file or directory
    gcc.exe: fatal error: no input files
    compilation terminated.

    ReplyDelete
    Replies
    1. same issue tell me if you get rid of it and how you get rid of it.

      Delete
  4. "{ .\for lopp }" ==> There should not be any spaces in the name of the file.

    ReplyDelete
  5. I have both dev c++ and vs code the problem is that both compilers are working at a same time when I am working on vs code pls help

    ReplyDelete
  6. how do i get vscode to give me the output in cmd as in the picture?

    ReplyDelete

Name

5G,1,Business,2,Bussiness,3,C,2,C++,4,CodeProject,3,Companies,5,Computer,1,Dev.to,1,Facebook,1,Featured,1,Future,2,Google,4,Javascript,2,Microsoft,2,Motivation,6,PHP,3,Programmer,6,Programming,14,Projects,1,Python,3,Quantum,1,Quora,10,Software Development,3,Tech,4,VS Code,2,
ltr
item
9to5Programmer: How to compile C/C++ program in VS Code
How to compile C/C++ program in VS Code
In this tutorial you'll learn how to compile and run a C/C++ code in Visual Studio Code. Visual studio code compile c++, visual studio code c++ hello world, g++ is not recognized visual studio code, compile and run c++ program in visual studio code, compile and run cpp in visual studio code, how to setup visual studio code for c++,
https://1.bp.blogspot.com/-bJ1tWuqV1so/XQaz_kjl8sI/AAAAAAAAtKo/Pu7nROp2tXULO76cMgISwynQiwvCmTEeACLcBGAs/s1600/1.jpg
https://1.bp.blogspot.com/-bJ1tWuqV1so/XQaz_kjl8sI/AAAAAAAAtKo/Pu7nROp2tXULO76cMgISwynQiwvCmTEeACLcBGAs/s72-c/1.jpg
9to5Programmer
http://www.9to5programmer.com/2019/06/how-to-compile-c-program-in-vs-code.html
http://www.9to5programmer.com/
http://www.9to5programmer.com/
http://www.9to5programmer.com/2019/06/how-to-compile-c-program-in-vs-code.html
true
1435496506228626257
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy