c - GCC/命令提示符错误 : '.' is not recognized as an internal or external command

标签 c gcc command-prompt

我对 C 还很陌生,对使用命令提示符和 GCC 来编译和运行我的程序也完全陌生。我正在努力寻找合适的词来正确地问这个问题,所以请耐心等待,我正在尽力而为。

我需要使用 GCC 来编译和运行这个 C 程序,但我收到了一个我不明白的错误。在这个示例程序中,我被告知使用这些行来编译和运行代码:

$ gcc -Wall -std=c99 -o anagrams anagrams.c 
$ ./anagrams  dictionary1.txt  output1.txt

这就是我所做的。 GCC 确实编译了程序文件,所以第一行没有给我任何错误。但是GCC不喜欢第二行,如下图:

C:\Users\...\Example>gcc -Wall -std=c99 -o anagrams anagrams.c
C:\Users\...\Example>./anagrams dictionary1.txt output1.txt
'.' is not recognized as an internal or external command,
operable program or batch file.

我到处都看到,它说要在编译后使用“./filename”来运行程序,所以我不明白为什么它对我不起作用。非常感谢任何帮助或建议。

此外,这里是程序的 main() 以显示为什么需要这两个 .txt 文件:

int main(int argc, char *argv[])
{
    AryElement *ary;
    int aryLen;

    if (argc != 3) {
        printf("Wrong number of arguments to program.\n");
        printf("Usage: ./anagrams infile outfile\n");
        exit(EXIT_FAILURE);
    }

    char *inFile = argv[1];
    char *outFile = argv[2];

    ary = buildAnagramArray(inFile,&aryLen);

    printAnagramArray(outFile,ary,aryLen);

    freeAnagramArray(ary,aryLen);

    return EXIT_SUCCESS;
}

最佳答案

'.' is not recognized as an internal or external command

这不是 GCC 错误。尝试运行命令时 shell 发出错误。

在 Windows 上这个

./anagrams  dictionary1.txt  output1.txt

应该是

.\anagrams  dictionary1.txt  output1.txt

在 Windows 上,路径分隔符是 \,而 IX'ish 系统是 /

在两个系统上 表示当前目录。


从您显示的最少来源来看,您在评论中提到的崩溃原因并不明显。这也是一个不同的问题。

关于c - GCC/命令提示符错误 : '.' is not recognized as an internal or external command,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36170646/

相关文章:

node.js - 与 unix 命令 'ls -lah' 等效的 Windows 命令提示符是什么?

c - 这个简单游戏的高效算法

c++ - 如何仅在C/C++项目中处理宏而不进行编译?

c++ - 对 std::__detail::_List_node_base::swap 的 undefined reference

c++ - 编译 proftpd 并在安装目录中包含库拷贝

c++ - 沙盒化可公开访问的 GCC

windows - windows xp下命令提示符最大化的方法

c - Borland C rand() 的实现

c - 完整桌面的 WinAPI 鼠标移动通知

c - 使用c程序清空回收站