Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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!

like image 431
tmnally Avatar asked May 03 '26 19:05

tmnally


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.
like image 117
Omar Trkzi Avatar answered May 05 '26 08:05

Omar Trkzi