Read A File
To read a file first we need to open the file and associate a pointer
with it, this pointer moves through the file and accesses every element of the file.
/*
http://www.ProbCOMP.com
In C langugage there are various functions available to work on files. To read a file first we need to open the file and associate a pointer
with it, this pointer moves through the file and accesses every element of the file. To mark the end of a file,C provides us with EOF constant.
*/
#include<stdio.h>
void main()
{
FILE *fp;
printf("enter the name of the file with the extension: ");
char filename[100];
scanf("%s",filename);
fp=fopen(filename,"rt");
int c=fgetc(fp);
while(EOF!=c)
{
printf("%c",c);
c=fgetc(fp);
}
}
Download Program


