Is there a way to chose where a program outputs text to a file ?(or read text from a file). As in selecting which line to start from.? Any help is welcome. :)

Only if the file is highly structured. seekg and seekp will position the file pointer at a specified number of bytes from the beginning of the file, but unless each line has exactly the same number of bytes, trying to place the pointer at the start of the desired line is almost impossible. A common alternative when files aren't perfectly predictable is to read the lines into a container which then makes it easier to find the desired line.

>As in selecting which line to start from.?
Sure, but unless the file is structured enough to seek, you'll have to actually read your way to the correct line. Writing is harder if you mean to insert rather than overwrite. In that case you need to save the subsequent lines and shift them over like you would insert into an array.

Comments
somewhat helpful

>As in selecting which line to start from.?
Sure, but unless the file is structured enough to seek, you'll have to actually read your way to the correct line. Writing is harder if you mean to insert rather than overwrite. In that case you need to save the subsequent lines and shift them over like you would insert into an array.

Thanks for your asuggestion I investigated the seekg and seekp functions and found them to be very useful, b ut it turns out that I didn't need them after all. ;)

This question has already been answered. Start a new discussion instead.