Write a program to read characters from 5 to 10.

#include<conio.h>
#include<stdio.h>
int main()
{
FILE *fp;
char ch;
int i=0,l=0;
fp=fopen("e:\\abc.txt","r");
if(fp==NULL)
printf("error to open");
fseek(fp,5,SEEK_SET);
while(1)
{
ch=fgetc(fp);
printf("%c",ch);
i=ftell(fp);
if(i==10||ch==EOF)
break;
}
fclose(fp);
}

No comments:

Post a Comment