这是我目前拥有的代码,但它似乎没有编译。任何帮助将非常感激。我需要创建一个程序,提示用户输入两个要读取的文件的名称。然后读取文件并显示统计信息
#include <stdio.h>
main (void)
{
FILE *textfile1;
FILE *textfile2;
int c;
char Filename;
printf("Enter the name of text file:");
scanf("%s", &Filename;
textfile1 = fopen(textfile1, "r");
if (textfile1 == NULL)
{
printf("File not found");
}
else
{
while (fscanf(textfile1, "%c", &textfile1) == 1)
{
printf("%c", textfile1);
}
fclose(textfile1);
}
}
什么是与你有什么事?它不以某种方式工作吗?请详细说明。 –
不会编译,它有2个错误。一个是缺少类型说明符 - int假定。注意:C++不支持default-int。第二个错误是'FILE'* fopen(const char *,char *)':不能将参数1从FILE *'转换为'const char *' – benjohnson29
'scanf(“%s”,&文件名;'缺少''' –