Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
164 views
in Technique[技术] by (71.8m points)

How to compile C program in Visual Studio Code?

I installed VSC and wrote this program

#include <stdio.h>

int main( void )
{
    printf("Hello world!");
}

Then I installed a C/C++ debugger and I saved the file on the desktop as "hello.c" and magically the syntax became higlighted.

Now I would like to run the program, but can't find a way.
There's no "run" or "build" option anywhere, and if I start the debugging and choose the debugger then I got a new tab named "settings.json" with a couple of brackets waiting for me to write something.

Also in the left I can read that I "have not yet opened a folder". What does it even mean?

And the line #include <stdio.h> is underlined in red, like there's something wrong going on, maybe I have to download the library?

I would do anything to see the output of the program, please help me.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Visual Studio Code in only a Text Editor you can't compile programs with it natively. You need an IDE for that. (Like Visual Studio)

You can try to compile the program from the terminal/CMD with GCC/Cygwin GCC.

For more info please read : https://code.visualstudio.com/docs/languages/cpp#_install-a-compiler


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...