嗨,我已经开始学习一点关于 FILE-pointer 以及如何打开文件等的知识。我正在阅读 Stephen Prata ( SamsPublishing )的 C Primer Plus Fifth Edition 书,我什至无法获得解决方案他们必须在我的项目中工作。
这是它的样子
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
int byte;
FILE * source;
int filect;
if (argc == 1)
{
printf("Usage: %s filename[s]\n", argv[0]);
exit(EXIT_FAILURE);
}
for (filect = 1; filect < argc; filect++)
{
if ((source = fopen(argv[filect], "r")) == NULL)
{
printf("Could not open file %s for input\n", argv[filect]);
continue;
}
while ((byte = getc(source)) != EOF)
{
putchar(byte);
}
if (fclose(source) != 0)
printf("Could not close file %s\n", argv[1]);
}
return 0;
}`
输出是:Usage:(Where my c project is located) filename[s] push any key to continue... 为什么会这样?