ionutdinulescu
Programmer
Hello.
I write some information into a binary file:
int iLevel
WideString sCode;
wofstream *f=new wofstream(s,ios::binary);
....
f.write((wchar_t*)&(iLevel),sizeof(int));
iLen=t->sCode.Length();
f.write((wchar_t*)&iLen,sizeof(int));
f.write(sCode.c_bstr(),iLen);
When I want to get it back:
wifstream* f=new wifstream(s.c_str(),ios::in|ios::binary);
wchar_t* c;
...
f->read((wchar_t*)&iLevel,sizeof(int));
f->read((wchar_t*)&iLen,sizeof(int));
f->read(c,iLen);
sCode=WideString(c);
I obtain the right iLevel and iLen, but Access violation occurs when trying to read variable c.
Can you find the problem ?
I write some information into a binary file:
int iLevel
WideString sCode;
wofstream *f=new wofstream(s,ios::binary);
....
f.write((wchar_t*)&(iLevel),sizeof(int));
iLen=t->sCode.Length();
f.write((wchar_t*)&iLen,sizeof(int));
f.write(sCode.c_bstr(),iLen);
When I want to get it back:
wifstream* f=new wifstream(s.c_str(),ios::in|ios::binary);
wchar_t* c;
...
f->read((wchar_t*)&iLevel,sizeof(int));
f->read((wchar_t*)&iLen,sizeof(int));
f->read(c,iLen);
sCode=WideString(c);
I obtain the right iLevel and iLen, but Access violation occurs when trying to read variable c.
Can you find the problem ?