Home > Blockchain >  How to create a C console application in Visual Studio Code
How to create a C console application in Visual Studio Code

Time:11-22

I haven't found any extension, or tutorial to make and execute a C console application in the VSCode Terminal.

A simple program like

int main()
{
    printf("Hello World!");

    return 0;
}

And have the output in the VSCode Terminal.

Does someone know how to realize this? And/or are there solutions?

Thanks in advance

Regards

CodePudding user response:

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 <stdio.h>

int main() {
    printf("Hello World!");

    return 0;
}
Hello World!

You even have a debugger, if you set certain breakpoints! Code halting on line 4, because a break point was set

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.

  • Related