GCC /命令提示错误:'.' 不被视为内部或外部命令

0 c gcc command-prompt

我是C的新手,对于使用命令提示符和GCC编译和运行我的程序来说,我是全新的.我正在努力找到正确的话来正确地提出这个问题所以请耐心等待我,我正在尽我所能.

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

$ gcc -Wall -std=c99 -o anagrams anagrams.c 
$ ./anagrams  dictionary1.txt  output1.txt
Run Code Online (Sandbox Code Playgroud)

这就是我所做的.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.
Run Code Online (Sandbox Code Playgroud)

在我看的每个地方,它都说在编译后使用"./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;
}
Run Code Online (Sandbox Code Playgroud)

alk*_*alk 5

'' 不被视为内部或外部命令

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

在Windows上

./anagrams  dictionary1.txt  output1.txt
Run Code Online (Sandbox Code Playgroud)

应该

.\anagrams  dictionary1.txt  output1.txt
Run Code Online (Sandbox Code Playgroud)

就像在Windows上一样,路径分隔符\与它所在的IX'系统相反/.

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


您在评论中提到的崩溃的原因并不是从您展示的最小来源中显而易见的.这也是一个不同的问题.