Register Now

Login

Lost Password

Enter your email to reset your password.

BY Author

The ftell() function

Syntax

long int ftell(FILE *fp);

This function is used to indicate the current position of the file indicator.
File position starts from zero.

Example

#include<stdio.h>
int main()
{
    FILE *fp;
    int curr_pos;

    fp=fopen("D:\\C Programming\\file8.txt","r"); // file opened in
                                                   // read mode	
    if(fp==NULL)
    {
        printf("\n Unable to open the FILE");
        return 1;
    }
	
    fseek(fp, 6, SEEK_SET); // position indicator placed at 6th position
	
    curr_pos = ftell(fp);
    printf("\n Current position of the file indicator = %d",curr_pos);
	
    fclose(fp);
    return 0;
}

Inside file8.txt

C Programming Language ftell Function in File Handling Example

Output

C Programming Language ftell Function in File Handling Example Output
 

Leave a reply