1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
/* fgetpos example */
#include <stdio.h>
int main ()
{
FILE * pFile;
int c;
int n;
fpos_t pos;
pFile = fopen ("myfile.txt","r");
if (pFile==NULL) perror ("Error opening file");
else
{
c = fgetc (pFile);
printf ("1st character is %c\n",c);
fgetpos (pFile,&pos);
for (n=0;n<3;n++)
{
fsetpos (pFile,&pos);
c = fgetc (pFile);
printf ("2nd character is %c\n",c);
}
fclose (pFile);
}
return 0;
}
|