Cpp-standard-library-cpp-stringbuf-pubseekoff
提供:Dev Guides
C ++ streambuf-pubseekoff
説明
内部位置ポインターを相対位置に設定し、同じ引数off、way、およびwhichを使用して保護仮想メンバーseekoffを呼び出します。
宣言
- 以下は、std
- basic_streambuf :: pubseekoffの宣言です。
pos_type pubseekoff (off_type off, ios_base::seekdir way,
ios_base::openmode which = ios_base::in | ios_base::out);
パラメーター
*off* -これは、ウェイパラメータに対するオフセット値です。
戻り値
変更された位置ポインタの新しい位置値を常に返します。
例外
基本的な保証-例外がスローされた場合、ストリームバッファは有効な状態です。
データの競合
ストリームバッファオブジェクトを変更します。
例
- 以下の例では、std
- basic_streambuf :: pubseekoffについて説明しています。
#include <iostream>
#include <fstream>
int main () {
std::fstream filestr ("sample.txt");
if (filestr) {
std::streambuf* pbuf = filestr.rdbuf();
long size = pbuf->pubseekoff(0,filestr.end);
std::cout << "The file size is " << size << " characters.\n";
filestr.close();
}
return 0;
}