Wednesday, May 10, 2017

fopen() validation

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

int main()
{
    FILE *fp = fopen("input.txt", "w");
    if (fp == NULL)
    {
        printf("File open error..");
        exit(0);
    }
    else
    {
        printf("File opened successfully..", fp);
        //Add your C File Management logic here.
    }
    fclose(fp);
    return 0;
}

Output of program

File opened successfully..

No comments:

Post a Comment