Mega Code Archive

 
Categories / C / File
 

Open a file for read

#include "stdio.h" int main() {     FILE *fp;          int letter;     if( ( fp = fopen( "my.txt", "r")) == NULL) {         puts("Cannot oepn the file");         exit( 0 );     }     while( ( letter = fgetc( fp ) ) != EOF)         printf("%c",letter);     fclose(fp); }