| | |
Selecting where to start from when reading or writing text to a file.
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Jul 2005
Posts: 1,678
Reputation:
Solved Threads: 263
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.
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.
I'm here to prove you wrong.
•
•
•
•
>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.
![]() |
Similar Threads
- How to install slackware (Not as easy as MEPIS) (Getting Started and Choosing a Distro)
Other Threads in the C++ Forum
- Previous Thread: string to int
- Next Thread: c++ interface?
| Thread Tools | Search this Thread |
api array arrays based beginner binary bitmap c++ c/c++ calculator char char* class code coding compile compiler console conversion count data database delete deploy developer dll download dynamiccharacterarray email encryption error file forms fstream function functions game getline givemetehcodez graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linker list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg sorting string strings struct temperature template text text-file tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






