fopen函数的使用

来源:互联网 发布:台州房销售数据下载 编辑:程序博客网 时间:2024/05/17 21:54

使用man命令


#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>


int main()
{
    FILE *fp;
    int error;


    fp = fopen("temp","r+");


    if(fp == NULL)
    {
        fprintf(stderr,"fopen() failed! error=%d\n",errno);
        perror("fopen()");
        fprintf(stderr,"fopen() failed! error=%s\n",strerror(errno));
        exit(1);
    }
    
    puts("ok!");


    exit(0);
}

运行结果:


1 0
原创粉丝点击