The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Vector Traversing dhanamurthy High Level Programming 1 04-30-2008 05:20 AM
backing up file everytime script run and saving other backups knc9233 UNIX for Dummies Questions & Answers 4 01-29-2007 05:21 AM
Control saving file by type saswerks UNIX for Dummies Questions & Answers 4 02-15-2005 12:47 PM
vector<string> with insert cmd photon High Level Programming 1 09-10-2004 02:51 PM
Saving a redirected file JSP UNIX for Dummies Questions & Answers 1 09-27-2001 03:52 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-26-2002
J.P's Avatar
J.P J.P is offline
Registered User
 

Join Date: Nov 2001
Location: Sweden
Posts: 67
Saving a vector to a file

Another C++ question, please do notify me if this forum is C-only!



I'm having a vector...

vector<Person> x;

... with a class I've defined (Person).

I have several elements in this vector and I would like to save it to a file (binary (?)). And later on open up this file to retrieve the elements in the vector.

Any suggestions on how to accomplish this?
__________________
[ Please put signature here ]
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 04-27-2002
Registered User
 

Join Date: Apr 2002
Posts: 13
First write the value of vector::size() to the file. And then write all the values in vector using a for-loop. The size will tell you (when reading from the file) how many vector values are present.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 06:32 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0