tell
io.h:インデックス への移動
ヘッダーファイル
io.h
カテゴリ
入出力ルーチン
プロトタイプ
long tell(int handle); __int64 _telli64(int handle);
説明
ファイルポインタの現在の位置を取得します。
tell は,handle に関連付けられたファイルの現在の位置を取得し,それをファイルの先頭からのバイト数で表します。
戻り値
tell は,現在のファイルポインタの位置を返します。戻り値 -1L
はエラーを示し,グローバル変数 errno に次の値が設定されます。
|
不正なファイル番号 |
例
#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; }
移植性
POSIX | Win32 | ANSI C | ANSI C++ |
---|---|---|---|
+ |