我的helloworld for C正在编译,但.exe文件没有运行?

时间:2017-07-18 21:32:23

标签: c powershell command-line mingw

我编写了这个简单的C Hello World程序,但我不知道它为什么不在命令行中工作?我使用MinGW C编译器,我按照网站说明下载了这个编译器,并且我使用Sublimetext作为我的文本编辑器。我编译程序很好似乎b / c .exe文件显示,但当我尝试运行该文件时打印

enter image description here

这个问题看起来非常基本,如果这个问题是业余的,那我就很糟糕,只是开始尝试学习C.

这是我的Sublime文本代码。

#include <stdio.h>

int main (){
    printf("Hello World\n");
    return 0;
}

1 个答案:

答案 0 :(得分:1)

您需要在PowerShell中指定可执行文件的目录。您可以选择通过cmd.exe启动该程序。

.\helloworld.exe

C:\Users\Zanel\OneDrive\documents\code\C\helloworld.exe

.代表当前目录。