problem when reading data from vector. 
Author Message
 problem when reading data from vector.

I create a file and write data into it use ofstream.
Then I read them from the file and push them into a vector.
I want to sort those data in the vector and re-write to that file using
ofstream. But I can't get them from the vector.

#include <vector>
typedef vector<char*> INTVECTOR;

  ofstream oftmp(pFileName,ios::out | ios::ate);
  oftmp << "IOS 2"<< endl;
  oftmp << "IOS 3"<< endl;
  oftmp << "IOS 4"<< endl;
  oftmp << "IOS 6"<< endl;
  oftmp.close();

   INTVECTOR theVector;
  ifPtr.open(pFileName);
  while(ifPtr.getline(buf, MAX_BUF_LEN - 1)) {
   theVector.push_back(buf);

  }

 ofstream ofPtr(pFileName, ios::out );
 while (!theVector.empty()) {
  ofPtr << theVector.front();
  theVector.erase(theVector.begin());
 }
 ofPtr.close();



Fri, 24 Oct 2003 13:52:58 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Problem initializing a vector of vectors

2. Problem reading data from TCP server using sockets!

3. reading in Image data problem...

4. EOF ? Problem with reading columns of data

5. Problems with reading columns of data

6. problem reading (unsigned char) data

7. read a value data (register) - LPDWORD problem

8. simple problem reading char data from a file

9. Problem with reading in simple data file

10. vector<string> data loss

11. How to read Vector Graphics in C# ??

12. Dynamic Array/Vector Data Structures HELP

 

 
Powered by phpBB® Forum Software