Tuesday, August 12, 2014

Program to read from file

Program to read from a file. If you have any doubts, let me know

#include <stdlib.h>
#include <stdio.h>
main()
{
char x, name[100];
FILE *pf;
    printf("Name of file?");
    gets(name);
    pf = fopen(name,"r");
    printf("Contents are :");
         while((x=fgetc(pf))!= EOF)
         printf("%c",x);
    }

No comments:

Post a Comment