Read Content From a File using Fgets

code:

#include<stdio.h>
#define SIZE 80
int main()
{
    FILE *fp;
    fp=fopen("E:/nosemsters/codes/crefresh/crefresh/c_for_technical_interview_udemy_course/file pointer/chk.txt","r");
    if(fp==NULL)
    {
        printf("unable to open file");
        return 0;
    }
    //prime read

    char names[SIZE];
    while(1){
    fgets(names,SIZE,fp);
    printf("%s",names);
    if(feof(fp))
        break;
    }
    fclose(fp);


    return 0;
}

 

It would be a great help, if you support by sharing :)
Author: zakilive

Leave a Reply

Your email address will not be published.