Hàm ftell trả về vị trí con trỏ file

long ftell(FILE *stream);

Parameter:

stream: con trỏ file

Remark:

Hàm ftell( ) trả về vị trí của con trỏ file hiện tại.

Ví dụ:

#include "stdio.h"
#include "conio.h"

void main()
{
    FILE *fp;
    char forum_name[] = "vncoding.net";
    char s[80];
    int res;

    if((fp = fopen("D:\\data.txt","w+")) == NULL)
        printf("\nError in opening file");
    else
    {
        fputs(forum_name, fp);

        res = ftell(fp);
        printf("\n position of file pointer: %d", res);

        fclose( fp );
    }
    getch(); 
}

Kết quả:

Hàm ftell trả về vị trí con trỏ file

 

Be the first to comment

Leave a Reply