我编写了一个从名为 network.dat 的文件中读取的代码
我写的代码是
f = fopen("network.dat", "r");
if(f == NULL)
exit(1);
int read, N;
printf("%p\n", f);//output file pointer, included this just to check if file is opened properly
fscanf(f, "%d%d", &N, &read);//error here
cout<<N;
该文件正在正确打开并且正在获取文件指针(49897488
)作为输出,但它后面的行是程序停止工作的地方,我没有得到N
作为输出。请告知是否需要其他详细信息。network.dat 的内容是
10 1
1 6 1.28646
1 7 1.2585
2 9 1.33856
等等。我只关注文件中的前 2 个数字,即 10 和 1。