|
-
September 25th, 2009, 08:32 PM
#1
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
-
September 25th, 2009, 08:54 PM
#2
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.
-
September 26th, 2009, 08:54 AM
#3
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.
Be sure to rate those who help!
-------------------------------------------------------------
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
-
September 27th, 2009, 03:20 AM
#4
Re: New to foundation class : CArchive
There is no need to over complicate the things. Use CStdioFile.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|