我对编程非常陌生,并且对“ hello,world”的基本启动程序有疑问。
我已经下载了MinGW,我相信我可以通过输入以下命令promt正确设置它: setx PATH "%PATH%;C:\MinGW\bin"
然后我在使用Notepad ++时遵循指南创建了此代码
#include <stdio.h>
int main(void)
{
puts("Hello, world!");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
保存在 c:/code/c/hello.c
当我尝试将其编译或在以下环境下运行时gcc -o hello hello.c
,出现此错误
gcc: error: hello.c: No such file or directory
gcc: fatal error: no input files
compilation terminated.
Run Code Online (Sandbox Code Playgroud)
我不确定如何解决此问题。我曾尝试环顾四周,但找不到任何答案,或者只是我听不懂。
gcc:错误:hello.c:没有这样的文件或目录 gcc:致命错误:没有输入文件编译终止。
意味着gcc
无法找到您的hello.c
源文件。您应该 cd 到源文件夹:
c:
cd c:\code\c\
gcc -o hello.exe hello.c
Run Code Online (Sandbox Code Playgroud)
或者在命令行中使用源的完整路径:
gcc -o c:\code\c\hello.exe c:\code\c\hello.c
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
17093 次 |
最近记录: |