c - C中文件操作期间的运行时错误

标签 c file

我正在尝试运行 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/

相关文章:

c - c 中的 SIGCHLD 处理程序 - 不必要的等待

python - 将 Python 对象转换为 C void 类型

c - 使用指针时 C 中的段错误

c - 通过引用函数调用进行阶乘递归?

c - epoll_wait with timerfd api 用于非阻塞读取

file - 挂载 Windows 文件共享 - 包含表情符号的文件导致 "Invalid Argument"错误

c - 在 C 中将矩阵保存到文件(.txt 格式)

c# - 上传时网络客户端超时

c - 如何在c中复制二进制文件

c++ - 从以分号分隔的文件中读取并存储到数组中