【发布时间】:2012-04-08 18:37:36
【问题描述】:
我正在编写一个在文件中维护linked_list 的程序。所以我遍历文件,使用 tellp()/tellg() 并将其添加到特定的长整数(可以看作是偏移量)以到达新位置。
一个简单的例子是
long next_offset = sizeof(long) + sizeof(int) ....
//like size of all the elements in the record, etc
curr_node = out.seekg();
while(curr_node != -1) {
out.read(...);
**curr_node.seekg(curr_node.tellp() + next_offset);**
out.read((char *)&curr_node,sizeof(long));
}
所以这里基本上我将 tellp() 值保存为 long 和 dng 长加法,这样可以吗?或者当 pos_value 变大时我可能会丢失一些位???
【问题讨论】:
标签: c++ file type-conversion long-integer fstream