How to create a C console application in Visual Studio Code

@Bodo I don't know how to try it, because I haven't found a documentation about how to do it. That's why I posted the question. Therefore, no, I haven't tried it.

Commented Nov 21, 2022 at 11:59

Actually I think this would be a fine question to have an answer for at Stack Overflow, wince it is quite narrow in scope, when you think about it.

Commented Nov 21, 2022 at 12:06 But build environment is important. Linux? Mac? Windows? If Windows, which C compiler/toolchain? Commented Nov 21, 2022 at 12:11 @hyde It would be on Windows and gcc Commented Nov 21, 2022 at 12:17

1 Answer 1

There actually is an extension for c/c++ on VSCode: Image of the extension When you click the arrow in the top right (to run the file) you will be asked which compiler you want to use. In our case we can use the gcc compiler: Screenshot of possible compilers for c

Then you can paste your code into a .c file and run it with the compiler. It should automatically also execute the binary and print your output into the debug-console:

#include int main()
Hello World! 

Code halting on line 4, <a href=because a break point was set" />

You even have a debugger, if you set certain breakpoints!

Extra: Make sure that you have the correct OS set in the bottom right (in the status bar), so your c code compiles for your machine specifically.