2

I've just downloaded VS Code, and am struggling to work out the basics of running any programs. I'm attempting to run a basic Hello World program in C:

#include<stdio.h>
int main() {
    printf("Hello, World!");
    return 0;
}

I found out that I needed to download a C compiler to run C programs on VS-Code, so I downloaded Visual Studio with C++ from the Microsoft website, which basically installed Visual Studio 2019. The heading on the link said "Develop C and C++ applications", so I figured it would at least let me program in C.

After doing this, in VS-Code I downloaded the C/C++ extension from Microsoft, and the Code Runner extension by Jun Han, which was recommended by a YouTube video. I then selected the Run Code (...environment? application?), and pressed the Play button on the top-right. The output in the terminal was:

[Running] cd "c:\Users\Leo\Documents\VSC Test Project\" && gcc test.c -o test && "c:\Users\Leo\Documents\VSC Test Project\"test
'gcc' is not recognized as an internal or external command,
operable program or batch file.

[Done] exited with code=1 in 0.078 seconds

I don't understand the error - so I opened Visual Studio 2019 to see if I could develop C applications in that. But no, only C++. Did Microsoft lie to me, or is there something else I need to do to configure C in VS2019?

Basically, I have no idea what I'm doing in VS-Code, and would really appreciate someone taking the time to break down how to actually run a program in there, and get C working. Or if there's a simple solution that allows me to write C in VS-2019, that would be equally great.

Lou
  • 2,200
  • 2
  • 33
  • 66
  • With VS there's a compiler config setting that controls whether it adheres to C or C++ standards, but Microsoft basically stopped support C decades ago, so you're better off using almost any other compiler, unless you really know what you are doingl. – jwdonahue Jun 01 '20 at 18:06
  • 1
    The error you posted indicates VS-Code is trying to run the gcc compiler and can't find it. – jwdonahue Jun 01 '20 at 18:08
  • 4
    GCC is a different compiler (from the MSVC compiler), and apparently the Code Runner uses it by default. So you can either install and setup a version of the GCC compiler for Windows (look into MinGW-w64, TDM-GCC, or MinGW), or you will need to configure the Code Runner to use the MSVC compiler instead. – isrnick Jun 01 '20 at 18:35

0 Answers0