Mega Code Archive

 
Categories / C / File
 

Get a string from a stream

#include <stdio.h> int main() {    FILE *file;    char string [100];    file = fopen ("my.txt" , "r");    if (file == NULL)         perror ("Error reading file");    else {      fgets (string , 100 , file);      puts (string);      fclose (file);    }    return 0; }