cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
file to vector, edit vector, vector to f
file to vector, edit vector, vector to file
Jun 13, 2011 at 8:09pm UTC
jmcco018
(1)
I am very confused on how to do this.
I have a file that tells you if a plane seat is available or not.
I want it so that upon the user booking a seat, the singular line that corresponds to that seat in my file is editted, leaving the rest the same.
What I have so far is:
vector<char> plane;
ifstream myfile("plane1.txt");
while(!myfile.eof())
{getline(myfile, line); plane.push_back(line); count++;}
plane.erase(plane.begin()+s);
plane.insert(plane.begin()+s, tempt);
ofstream out("plane1.txt", ios::out || ios::binary);
std::vector<plane>::iterator pos(plane.begin());
for(pos; pos !=plane.end(); pos++)
{
out.write ???????
}
where s is decided by the row/column combination and tempt is entered by the user.
Am I going in the right direction? Also, what libraries do I need to include in my .cpp?
Topic archived. No new replies allowed.