How to directly access a certain part of a text file in g++?
问题 I have a text file containing a number of records. Each record is stored on a single line that is 100 characters long. Let's say I want to directly access the nth record. I could do it using a for loop, reading in n lines until I get to the record. But how could I access it directly? 回答1: If the each line is exactly 100 characters long and the line ending is always \n (i.e. no \r\n stuff) and there's no blank lines and people won't use 1 tab for 8 spaces etc. you can use (with ifstream) fin