我有以下C++方案,利用Windows 2008视力演播室进行。 7. 基本生活 我的特性是,然后是没有目标。 在这样做之后,档案位置不同。 为什么? 我如何处理这个问题?
测试.txt(如果你愿意,下载链连接以下)
/* Comment 1 */
/* Comment 2 */
#include <fstream>
int main (int argc, char ** argv) {
char const * file = "test.txt";
std::fstream fs(file, std::ios::in);
std::streampos const before = fs.tellg();
// replacing the following two lines with
// char c = fs.peek(); results in the same problem
char const c = fs.get();
fs.unget();
std::streampos const after = fs.tellg();
fs.seekg(after);
char const c2 = fs.get();
fs.close();
return 0;
}
c: 47 / char
c2: -1 ÿ char
before: {_Myoff=0 _Fpos=0 _Mystate=0 } std::fpos<int>
after: {_Myoff=0 _Fpos=-3 _Mystate=0 } std::fpos<int>
添加<条码>:fstream:binary到构造者看来可以解决这个问题。 也许它必须处理档案中的新路线? 如果是,它为什么会影响甚至接近阅读新线的法典?
更新后,寻求后一种立场并具有另一种特性。
似乎通过“灯塔”来节约。 举足轻重。 通过“灯塔”进行救助,使下游工作变得oka。
我将文件上载到洞gle角,如果你想把文件 d起来的话: