I'm fairly new to C and am completely new to using the command prompt and GCC to compile and run my programs. I'm struggling to find the right words to ask this question properly so please bear with me, I am doing my best.
我是C的新手,使用命令提示符和GCC来编译和运行我的程序是全新的。我正在努力找到正确的话来正确地提出这个问题所以请耐心等待我,我正在尽我所能。
I need to use GCC to compile and run this C program but I'm getting an error that I do not understand. In this example program, I was told to use these lines to compile and run the code:
我需要使用GCC来编译和运行这个C程序,但是我收到一个我不理解的错误。在这个示例程序中,我被告知使用这些行来编译和运行代码:
$ gcc -Wall -std=c99 -o anagrams anagrams.c
$ ./anagrams dictionary1.txt output1.txt
So that is what I did. GCC does compile the program file, so the first line does not give me any error. But GCC does not like the second line, as shown below:
这就是我所做的。 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.
Everywhere I look, it says to use "./filename" to run the program after compiling so I don't understand why it is not working for me. Any help or advice would be really appreciated.
在我看的任何地方,它都说在编译后使用“./filename”来运行程序,所以我不明白为什么它对我不起作用。任何帮助或建议将非常感激。
Also, here is the main() of the program to show why those two .txt files are needed:
另外,这里是程序的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;
}
1 个解决方案
#1
5
'.' is not recognized as an internal or external command
''不被视为内部或外部命令
This is not a GCC error. The error is issued by the shell when trying to run a command.
这不是GCC错误。尝试运行命令时,shell会发出错误。
On Windows this
在Windows上
./anagrams dictionary1.txt output1.txt
should be
.\anagrams dictionary1.txt output1.txt
as on Windows the path delimiter is \
as opposedto IX'ish systems where it is /
.
在Windows上,路径分隔符是\,而不是IX'系统,它是/。
On both systems .
denotes the current directory.
在两个系统上。表示当前目录。
The reason for the crash you mention in your comment is not obvious from the minimal sources you show. Also this is a different question.
您在评论中提到的崩溃的原因并非从您显示的最小来源中显而易见。这也是一个不同的问题。
#1
5
'.' is not recognized as an internal or external command
''不被视为内部或外部命令
This is not a GCC error. The error is issued by the shell when trying to run a command.
这不是GCC错误。尝试运行命令时,shell会发出错误。
On Windows this
在Windows上
./anagrams dictionary1.txt output1.txt
should be
.\anagrams dictionary1.txt output1.txt
as on Windows the path delimiter is \
as opposedto IX'ish systems where it is /
.
在Windows上,路径分隔符是\,而不是IX'系统,它是/。
On both systems .
denotes the current directory.
在两个系统上。表示当前目录。
The reason for the crash you mention in your comment is not obvious from the minimal sources you show. Also this is a different question.
您在评论中提到的崩溃的原因并非从您显示的最小来源中显而易见。这也是一个不同的问题。