C fgets function is implemented in file related programs for reading strings from any particular file. It gets the strings 1 line each time.

char *fgets(char *str, int n, FILE *stream)
void main(void)
    FILE* fileName;
    char ch[100];
    fileName = fopen("anything.txt", "r");
    printf("%s", fgets(ch, 50, fileName));
  • On success, the function returns the same str parameter
  • C fgets function returns a NULL pointer in case of a failure.