File Handling in c : Reading to a file
Posted by Unknown
0
comments
Need of File Handling:
The data that is generated by programs will be lost when the
program is terminated. Hence for later use we need to store the information at
some place and this place is FILE.
File is a medium to store and later retrieve information.
File operations:
1.
Create
2.
Open
3.
Read
4.
Write
5.
Close
6.
Seek
Example: Reading the content of file àabc.txt
#include<stdio.h>
#include<conio.h>
void main()
{
FILE *fp;
char ch;
fp=fopen(“abc.txt”,”r”);
while(1)
{
Ch=fgetc(fp);
If(ch==EOF)
{
break;
}
printf("%c",ch);
}
fclose(fp);
}



