/* program to understand the use of ftell() */
Employee
{
empid;
name[30];
salary;
}emp;
main()
{
*fptr;
fptr=fopen("myfile","rb");
(fptr==NULL)
{
printf("error in opening file \n" );
(1);
}
printf("position indicator in the beginning -- %ld \n", ftell(fptr));
(fread(&emp,sizeof(emp),1,fptr)==1)
{
printf("position indicator-- %ld \n", ftell(fptr));
printf("%s \n", emp.name);
printf("%d \n", emp.empid);
printf("%f \n", emp.salary);
}
printf("%d \n", ftell(fptr));
fclose(fptr);
0;
}
|