Study of file i/o - 2 Reading characters from a file with fgetc( ).

#include <stdio.h>

int main(void)
{
FILE *fp;
char ch;

fp = fopen("sample" , "r");

if(fp == NULL)
{
printf("\nUnable to open file for reading");
return 1;
}

do
{
ch = fgetc(fp);
printf("%c ", ch);
}while(ch != EOF);
// }while(!feof(fp));

fclose(fp);

return 0;

}

No comments:

Post a Comment

kiss on google ads if you are anonymous because your ip is trackable.thank you.

......from.admin