getline at a certain line for file IO
Posted
by BSchlinker
on Stack Overflow
See other posts from Stack Overflow
or by BSchlinker
Published on 2010-05-09T18:57:29Z
Indexed on
2010/05/09
19:08 UTC
Read the original article
Hit count: 450
Is there anyway to use getline to read a specific line within a file? For instance, to immediately read line #20?
It seems inefficient to do any type of look to read and discard earlier lines. I know about fseek, but there is no guarantee that the records will be the same length on each line.
I imagine this is simply what is required in order to find lines. After all, to know when the end of the line has been reached, it needs to find the break line character, so it makes sense for it to need to read each line.
Just wondering if there was any quicker method.
© Stack Overflow or respective owner