C program to read data from file.

Posted by Mangesh on March 31, 2018

/* C program to read data from file. */

Description :

We want to read data from file using C language and display it on the screen.

Program :

#include<stdio.h>
#include<conio.h>
void main()
{
  char data[1000];
  FILE *file;
  file = fopen("data.txt","r");
  if(file == NULL){
    printf("File is empty!!!");
  }
  else{
    fscanf(file,"%[^\0]",&data);
    printf("data : %s",data);
  }
  fclose(file);
  getch();
}

Output :

c program for read file Executed and Tested in Turbo C 3.2

Written with from Mangesh.

Related Post
1 C program to read data from file.
2 C program to write data into file.
3 C program to delete the File.
Latest Post
1 shubhanshu
2 test
3 C program for Breadth First Search.
4 C program for Depth First Search(DFS).
5 C for circular queue using linked list.