专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > WinCE

CE下字符串写入文件出错,怎么处理那

发布时间:2010-06-13 22:15:29 文章来源:www.iduyao.cn 采编人员:星星草
CE下字符串写入文件出错,怎么办那?
我在CE下要向文件里写一些字符串。可是写入的时候出错,我以前用这代码在WIN32下好使的。请问怎么办
CStdioFile*   pFile   =   new   CStdioFile(FileName,CFile::modeWrite|CFile::modeCreate);

CString   code;
code.Format(L "P0%d     X%f,   Y%f,   Z%f,   U%f,   V%f,   W%f,   R%f,   S%f,   H%d   \n ",
count,angle[0],angle[1],angle[2],angle[3],angle[4],angle[5],
angle[6],speed,hand);

pFile-> WriteString(code);//这里提示错误说没有此函数,怎么办那
pFile-> Close();
delete   pFile;

我又用另一种方法写了下
CFile   myFile(FileName,   CFile::modeCreate   |   CFile::modeReadWrite);
CArchive   arStore(&myFile,   CArchive::store);
code.Format(L "P0%d     X%f,   Y%f,   Z%f,   U%f,   V%f,   W%f,   R%f,   S%f,   H%d   \n ",
count,angle[0],angle[1],angle[2],angle[3],angle[4],angle[5],
angle[6],speed,hand);
arStore.WriteString(code);
arStore.Close();

这样可以写进去了但是,写到里面的数据每个字符间都有个空格,如何解决那,请高手教我了。谢谢!

------解决方案--------------------
有空格(基本不影响文件读写的,不过如果写到xml文件中可能会有问题)是因为你写进去的是unicode的字符,把code里面的内容转化成char类型的保存到文件中就ok了
------解决方案--------------------
多字节和宽字符之间转换的函数:mbstowcs, mbtowc, wcstombs, wctomb.
mbstowcs---Convert a multi-byte(ANSI) string to wide character stirng(Unicode).
wcstombs---Convert a wide character string to multi-byte string.
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: