Click here to Skip to main content
15,947,338 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Visual Studio 2005 MFC Combo Box Pin
begin812-May-12 14:20
begin812-May-12 14:20 
GeneralRe: Visual Studio 2005 MFC Combo Box Pin
begin812-May-12 14:53
begin812-May-12 14:53 
GeneralRe: Visual Studio 2005 MFC Combo Box Pin
Richard MacCutchan2-May-12 22:03
mveRichard MacCutchan2-May-12 22:03 
QuestionLine breaks in (Rich) edit control Pin
ForNow1-May-12 11:22
ForNow1-May-12 11:22 
AnswerRe: Line breaks in (Rich) edit control Pin
Code-o-mat1-May-12 21:26
Code-o-mat1-May-12 21:26 
GeneralRe: Line breaks in (Rich) edit control Pin
ForNow2-May-12 0:07
ForNow2-May-12 0:07 
GeneralRe: Line breaks in (Rich) edit control Pin
Code-o-mat2-May-12 0:12
Code-o-mat2-May-12 0:12 
Questionboost serialization/deserialization strange problem Pin
dliviu30-Apr-12 22:03
dliviu30-Apr-12 22:03 
hello

I have installed boost 1.47.0 library on my system and I have a strange problem. If I try to serialize more then 25 objects, the serialization (save()) apparently works but the deserialization (load()) does not work anymore and it gives me the following error:

Unhandled exception at 0x7c812afb in Boost_tests.exe: Microsoft C++ exception: boost::archive::archive_exception at memory location 0x0012e5ec..

this error is raised when the last object (say the 26th object, if the number of objects is higher then 25) is being deserialized.

here is the code:

#include <boost/archive/binary_oarchive.hpp> 

#include <boost/archive/binary_iarchive.hpp> 

#include <boost/serialization/string.hpp> 

#include <iostream> 

#include <string> 

#include <fstream>

#include <vector>

using namespace std;

#define COUNT 26


class person;

vector<person> v;

class person

{

public:

string _name;

int _age;

person (string name="Liviu", int age=40):_name(name),_age(age){};

friend class boost::serialization::access;


template <typename Archive> 

void serialize(Archive & ar, const unsigned int version)

{

ar & _name;

ar & _age;

}

};


void save() 

{ 

ofstream file("archiv.cst"); 

boost::archive::binary_oarchive oa(file); 


for (int i=1; i<=COUNT; i++)

{

oa<<person("John",i);

}

file.close();

}; 

void load() 

{ 

ifstream file("archiv.cst"); 

boost::archive::binary_iarchive ia(file); 


for (int i=1; i<=COUNT; i++)

{

person p;

ia>>p;

v.push_back(p);


// cout << p._name<<" " <<p._age<<endl; 

}

file.close();

};


int main() 

{ 

int i;

cin>>i;

while (i!=2)

{

if (i==0) save();

if (i==1) load();

cin>>i;

}

} 


Can you help me please? Is something wrong with the library?
AnswerRe: boost serialization/deserialization strange problem Pin
Richard MacCutchan30-Apr-12 23:07
mveRichard MacCutchan30-Apr-12 23:07 
GeneralRe: boost serialization/deserialization strange problem Pin
dliviu1-May-12 0:36
dliviu1-May-12 0:36 
GeneralRe: boost serialization/deserialization strange problem Pin
Richard MacCutchan1-May-12 0:42
mveRichard MacCutchan1-May-12 0:42 
GeneralRe: boost serialization/deserialization strange problem Pin
dliviu1-May-12 0:48
dliviu1-May-12 0:48 
GeneralRe: boost serialization/deserialization strange problem Pin
Richard MacCutchan1-May-12 1:11
mveRichard MacCutchan1-May-12 1:11 
GeneralRe: boost serialization/deserialization strange problem Pin
dliviu1-May-12 1:19
dliviu1-May-12 1:19 
AnswerRe: boost serialization/deserialization strange problem Pin
Albert Holguin1-May-12 4:09
professionalAlbert Holguin1-May-12 4:09 
GeneralRe: boost serialization/deserialization strange problem Pin
dliviu1-May-12 20:53
dliviu1-May-12 20:53 
GeneralRe: boost serialization/deserialization strange problem Pin
Albert Holguin2-May-12 5:30
professionalAlbert Holguin2-May-12 5:30 
QuestionGetClipBoardOwner with acrobat reader Pin
randydom30-Apr-12 19:35
randydom30-Apr-12 19:35 
AnswerRe: GetClipBoardOwner with acrobat reader Pin
Richard MacCutchan30-Apr-12 23:03
mveRichard MacCutchan30-Apr-12 23:03 
GeneralRe: GetClipBoardOwner with acrobat reader Pin
randydom1-May-12 1:23
randydom1-May-12 1:23 
GeneralRe: GetClipBoardOwner with acrobat reader Pin
Richard MacCutchan1-May-12 1:51
mveRichard MacCutchan1-May-12 1:51 
GeneralRe: GetClipBoardOwner with acrobat reader Pin
randydom1-May-12 1:58
randydom1-May-12 1:58 
GeneralRe: GetClipBoardOwner with acrobat reader Pin
Richard MacCutchan1-May-12 2:05
mveRichard MacCutchan1-May-12 2:05 
GeneralRe: GetClipBoardOwner with acrobat reader Pin
randydom1-May-12 2:22
randydom1-May-12 2:22 
QuestionRe: GetClipBoardOwner with acrobat reader Pin
David Crow1-May-12 3:49
David Crow1-May-12 3:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.