| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi,
I am trying to figure out how to read and write from files using ifstream and ofstream I use seekp() to get to the needed position in the file put(), write() or << to write into the file, but as a result I get the data in the right place, but everythin else is empty spaces, all other text from the file disappears. I used ios::ate to disable default ios::trunc in construction. Maybe some other flag chould be used? Anyway, I need help on the topic and maybe a link to the complex example on reading and writing to files (and not only appending at the end) Thanks |
|
#2
|
|||
|
|||
|
Hi,
Do not use ios::app. Use seekp to go to the specified location. Save the contents from the specified location to the end of the file in a buffer or else it will be overwritten. Write the data in the specified location. Write the saved data from the buffer to the file. Thats it ... ![]() |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > Writing into specific place in file (C++) |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|