Cannot open source file "stdio.h" in Visual Studio Code

Viewed 10118

I'm new to C and this is my first project using visual studio. I have #include <stdio.h> in the first line of the code but there is an error "cannot open source file "stdio.h" C/C++ (1696)". I have installed the Microsoft C/C++ extension. I am happy to clarify anything. Thank you!

1 Answers

Note:

Be aware that VSCode is simply an editor. With some extensions installed, it may help you code "faster & easier".

The C/C++ extension that I use


Solution:

But in order for you to compile the code it is less beginner friendly than IDEs like CodeBlocks.

The way I do it is by going to :

  • Terminal > New terminal
  • cd "the_directory_in_which_the_file.c_exists" (don't forget the double quotes)
  • gcc "file.c"
  • ./a.out (./a.exe on Windows)

Example: Hello Stackoverflow !


Just in case:

  • if gcc (the compiler in this case) is not installed, then you can quickly do so by following this article's steps if you use Windows, or this one if you are on Linux.
Related