我正在尝试从代码中打开两个文件,但在尝试从 first.txt 获取我的三个数字时遇到了麻烦,但它只打印第一个。我只需要帮助打印我的文本文件中的所有数字,因此无需完成我的整个程序,但欢迎提出建议:)!
int main(int argc, char **argv)
{
int *number1Pointer = malloc(80 * sizeof(int));
FILE *file1;
//FILE *file2;
file1 = fopen("first.txt", "r");
//file2 = fopen("second.txt", "r");
int read = fscanf(file1, "%d", number1Pointer);
if(read != '\0')
{
printf("%d", &number1Pointer);
}
else
{
fclose(file1);
}
return 0;
}