Archived

This topic is now archived and is closed to further replies.

easy file question

This topic is 5025 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

using c++, i have a text file that i want to have text inserted into at the begining of the file. How do i set the stream output to the beginging of the file? ie. if i wanted to insert the string "Hello there you" into tedxtfile.txt, the result would be textfile.txt: "Hello there you" sdfjh dsf asd f sdfksjdfkjsdf sdfsdfdsf thanks

Share this post


Link to post
Share on other sites
honestly, using nothing but standard function you cannot do this operation "in place" ... you must use a temporary file to do it - ie: make a temp file, copy first stuff into it, copy old file into it, close it, delete old file, move temp to old filename.

sucks doesn''t it

Share this post


Link to post
Share on other sites
Or read the whole file into memory and spit it back out again. Either way, there isn''t direct support for insertion into a file within standard C++.

Share this post


Link to post
Share on other sites