How to Read Data from File in C Programming

Get Certified in C Programming and Take Your Skills to the Next Level

Program 1

// Program for read data from file
#include<stdio.h>
#include<conio.h>
void main()
{
    FILE *fp=NULL;
    char ch;
    int csp=0,cc=0,cl=0;
    fp=fopen("e://cdata/employee.txt","r");   // Read mode
    if(fp==NULL)  //check file
    printf("\nFile not open....\n");
    else
    {
       do
       {
           ch=fgetc(fp);
           printf( “%c,ch”);
       }while(ch!=EOF);

   fclose(fp);
    }

 

Your 15 seconds will encourage us to work even harder
Please share your happy experience on Google

courses

TechVidvan Team

TechVidvan Team provides high-quality content & courses on AI, ML, Data Science, Data Engineering, Data Analytics, programming, Python, DSA, Android, Flutter, full stack web dev, MERN, and many latest technology.

Leave a Reply

Your email address will not be published. Required fields are marked *