1
0

readFile.c 384 B

12345678910111213141516171819
  1. /* fgets example
  2. * http://www.cplusplus.com/reference/cstdio/fgets/
  3. */
  4. #include <stdio.h>
  5. int main()
  6. {
  7. FILE * pFile;
  8. char mystring [100];
  9. pFile = fopen ("myfile.txt" , "r");
  10. if (pFile == NULL) perror ("Error opening file");
  11. else {
  12. if ( fgets (mystring , 100 , pFile) != NULL )
  13. puts (mystring);
  14. fclose (pFile);
  15. }
  16. return 0;
  17. }