Below is C program toRead text file .
Program:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | /* Read text file */ #include<stdio.h> int main() { FILE *fp; int ch; fp= fopen ( "myfile.txt" , "r" ); if (fp==NULL) { printf ( "Can't find the source file." ); return 1; } while (1) { ch= fgetc (fp); if ( feof (fp)) break ; printf ( "%c" ,ch); } fclose (fp); return 0; } |
No comments:
Post a Comment