Connecting Tech Pros Worldwide Forums | Help | Site Map

How to modify a file which contains a vector?

Newbie
 
Join Date: May 2007
Posts: 5
#1: May 3 '07
For example I have a file vector.dat with a vector. I need to modify some elements in the middle of the vector.
I try to do it with the functions write and seekp, but then the rest of data is lost.
How to do it in a proper way?

Banfa's Avatar
AdministratorVoR
 
Join Date: Feb 2006
Location: South West UK
Posts: 6,195
#2: May 3 '07

re: How to modify a file which contains a vector?


You are probably opening the file in the wrong mode so that it gets truncated or something like that.
Newbie
 
Join Date: May 2007
Posts: 5
#3: May 4 '07

re: How to modify a file which contains a vector?


Look, i do like this
ofstream outCredit( "in.dat", ios::binary );
So maybe there is a special ios-mode to avoid this truncation?
Newbie
 
Join Date: May 2007
Posts: 5
#4: May 4 '07

re: How to modify a file which contains a vector?


Solved. I need to declare it as fstream. Thanks!!!
Reply