New to foundation class : CArchive
I use CArchive to store a string
into a file
But I always get an odd character (a square shaped) on top of the file,
--------
Cfile f("t.txt",Cfile::modecreate|cfile:modewrite);
CArchive ar(&f,carchive::store);
Cstring s="show me the square";
ar<<s;
--------
Could you help me please ? :(
Thank you
Re: New to foundation class : CArchive
CArchive doesn't write text files. It adds other information in there. Use CStdioFile if you want to write plain text.
Re: New to foundation class : CArchive
When writing a CString with CArchive, the length of the string is also written to the file. This is done so that the CArchive::Load will know the size.
If you have MBCS character set used, you'll see the length as the first byte (if the string is less than 254 characters) - so that's the square that you see.
Re: New to foundation class : CArchive
There is no need to over complicate the things. Use CStdioFile.