Study of file i/o - 4 Reading strings from a file with fgets( ).

#include <stdio.h>

int main(void)
{
FILE *fp;
char name[30];

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

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

for( ; fgets(name, 7, fp) != NULL ; )
printf("\n%s", name);


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