C Program to read a text file
Program
#include<stdio.h>
#include<stdlib.h>
void main()
{
FILE *file_ptr;
int buf;
file_ptr = fopen("read.txt", "r");
if(!file_ptr)
{
printf("Unable to open file\n");
exit(0);
}
else
printf("File open successful\n");
fclose(file_ptr);
}
Output 1
File open successful
Output 2
Unable to open file