C-bash中的第一个程序:./:是一个目录

问题描述

我在vim中用C语言编写了一个简短的第一个程序。

int main() {
        printf("Das ist mein erstes Programm. \n");
        return 0;
}

然后我用

进行编译
cc -o hello.out hello.c
./ hello.out

昨天我可以在控制台中看到文本“ Das ist mein erstes Programm”。

今天我只看到:

-bash: ./: is a directory

我没有更改代码中的任何内容。有谁知道为什么我现在会“是目录”?

非常感谢

解决方法

尝试使用:

cc -o hello.out hello.c && ./hello.out

您正试图通过在./hello.out之间留一个空格来执行二进制文件:

cc -o hello.out hello.c ./ hello.out
                        ^^^^^^^^^^^^

终端将./解释为目录。