简体   繁体   English

无法在 Visual Studio Code 中打开源文件“stdio.h”

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

I'm new to C and this is my first project using visual studio.我是 C 新手,这是我使用 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)".我在代码的第一行中有#include <stdio.h>,但出现错误“无法打开源文件“stdio.h”C/C++ (1696)”。 I have installed the Microsoft C/C++ extension.我已经安装了 Microsoft C/C++ 扩展。 I am happy to clarify anything.我很高兴澄清任何事情。 Thank you!谢谢!

Note:笔记:

Be aware that VSCode is simply an editor .请注意, VSCode只是一个编辑器 With some extensions installed, it may help you code "faster & easier".安装一些扩展后,它可以帮助您“更快、更轻松”地编写代码。

我使用的 C/C++ 扩展


Solution:解决方案:

But in order for you to compile the code it is less beginner friendly than IDEs like CodeBlocks .但是为了让您编译代码,它对初学者的友好性不如CodeBlocks 之类的 IDE。

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 ) cd "the_directory_in_which_the_file.c_exists"不要忘记双引号
  • gcc "file.c"
  • ./a.out ( ./a.exe on Windows) ./a.out上的./a.exe

示例:你好 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.如果没有安装gcc (在这种情况下是编译器),那么如果您使用 Windows,则可以按照本文步骤快速安装,如果您使用的是 Linux,则可以按照本文的步骤进行操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM