2010-03-25 81 views

回答

4

如果每个线长正好是100个字符和线条的结局总是\n(即没有0​​的东西),而且也没有空行和人民赢得了“T使用1片为8个空格等就可以使用(与ifstream的)

fin.seekg(101 * n, ios::beg); // Assume the initial record has n=0. 

或(与FILE *)

fseek(f, 101 * n, SEEK_SET); 

如果您不确定任何前提条件,请使用循环。

0

,你可以利用的seekg功能:

ifstream is("test.txt"); 
is.seekg ((n-1)*100, ios::beg); // move the get pointer to the beg of nth record.