Tuesday, 9 December 2014

fseek,ftell importance through program
#include"myHeader.h"
main()
{
int pos;
char str[20]="abcdefgh";
FILE *fp;
fp=fopen("madan","r");
if(fp==NULL)
{
printf("no data\n");
return;
}
fseek(fp,4,0);
pos=ftell(fp);
printf("%c ",str[pos]);
fseek(fp,3,1);
pos=ftell(fp);
printf("%c ",str[pos]);
fseek(fp,-1,1);
pos=ftell(fp);
printf("%c ",str[pos]);
//fseek(fp,0,0);
//pos=ftell(fp);
rewind(fp);
printf("%c ",str[pos]);
fclose(fp);
}
OutPut:
e h g g