-1
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
char ch1;
char ch = 'A';
fstream fileout("data.dat",ios::out);
fileout << ch;
int p = fileout.tellg();
cout << p;
}
それは1を返しますか? 'A'はファイルの最初のバイトですか?私はtellg関数の働きを理解していないようです
この場合、書き込みアクセスのみでファイルを開いたので、 'tellp'を使用してください。 * std :: basic_filebufは1つのファイルしか保持しないので、基本クラスの関数シグネチャで必要とされるopenmode引数は、通常は無視されます** ** tellg'は入力位置インジケータを返すので意味がありません。ポジション* - cppreference.com – BeyelerStudios
@Olaf質問はcs.seから移行されました。 –