ftell() function in C Programming Language

 //use of ftell() function in c

ftell() function is used to return the position of the pointer in file.

#include<stdio.h>

void main()

{

    FILE *fptr;

    int pos;

    fptr=fopen("C:\\students\\batch8am-9am\\test.txt","w+");

    if(fptr!=NULL)

    {

        fprintf(fptr,"hello");

        pos=ftell(fptr);

        printf("\n pointer location is %d",pos);

        fprintf(fptr," vani");

        pos=ftell(fptr);

        printf("\n pointer location is %d",pos);

        fclose(fptr);

    }


}//end of main

Output of the program is :



Comments