我已经以二进制模式打开了一个文件,下面的操作给出x的负值。我打开的文件大小约为2.5 GB。
infile.seekg(0, ios::end);
__int64 x = infile.tellg();
Run Code Online (Sandbox Code Playgroud)
我需要infile读取字节(无符号字符),因此我uifstream通过执行以下操作将其定义为:
typedef basic_ifstream<unsigned char, std::char_traits<unsigned char> > uifstream;
Run Code Online (Sandbox Code Playgroud)
这基本上是标准的ifstream,但使用unsigned chars代替chars。
编辑:我正在使用Visual Studio 2005,并将uofstream更正为uifstream。