Header File
io.h
Category
Input/output Routines
Prototype
long tell(int handle);
Description
Gets the current position of a file pointer.
tell gets the current position of the file pointer associated with handle and expresses it as the number of bytes from the beginning of the file.
Return Value
tell returns the current file pointer position. A return of -1 (long) indicates an error, and the global variable errno is set to
EBADF |
Bad file number |
Example
#include <string.h> #include <stdio.h> #include <fcntl.h> #include <io.h> int main(void) { int handle; char msg[] = "Hello world"; if ((handle = open("TEST.$$$", O_CREAT | O_TEXT | O_APPEND)) == -1) { perror("Error:"); return 1; } write(handle, msg, strlen(msg)); printf("The file pointer is at byte %ld\n", tell(handle)); close(handle); return 0; }
Portability
POSIX |
Win32 |
ANSI C |
ANSI C++ |
|
+ |
|
|
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|