zzy-c

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>
#include<string.h>
#include<assert.h>
#include<errno.h>
//strerror//把错误码转换为错误信息
//perror//打印错误信息
int main()
{
    //打开文件失败的时候,会返回NULL
    FILE* pf = fopen("test1.txt", "r");
    if (pf == NULL)
    {
        //printf("%s\n", strerror(errno));
        perror("fopen");
        return 1;
    }
    //读文件
    //关闭文件
    fclose(pf);
    pf = NULL;

    return 0;
}

 

posted on 2022-04-11 15:44  zzy_C  阅读(96)  评论(0)    收藏  举报