我正在尝试运行 C 代码来打开文件,每当我这样做时,我都会收到一条调试断言失败的消息。
这是我的代码:
#include<stdio.h>
#include<stdlib.h>
void main()
{
FILE *fp1;
printf("program to demonstrate file operations");
fp1 = fopen("try1.txt","r");
if (feof(fp1))
{
printf("Yes");
}
else
printf("No");
printf("%f",fp1);
getchar();
}
最佳答案
Debug断言失败可能是因为fp1
为null。
如果文件无法打开,就会发生这种情况。
关于c - C中文件操作期间的运行时错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28185388/