MFC输出到txt问题
时间:2011-12-02
来源:互联网
             本人基本小白一只,下周二要交的大作业,求各位大神帮忙~
要求是基于对话框编写一个通讯录程序。之前有做过控制台的,用的是i/o流输入输出,但是把原来的string改成CString了之后输出的都是乱码。
ofstream outfile ("AddressBook.txt",ios::out|ios::app);//打开文件
outfile<<name<<" "<<birthYear<<" "<<birthMonth<<" "<<birthDay<<" "<<telnumber<<" "<<email<<'\n';
//name,telnumber,email,为cstring型,birthYear,birthMonth,birthDay,为int型
            要求是基于对话框编写一个通讯录程序。之前有做过控制台的,用的是i/o流输入输出,但是把原来的string改成CString了之后输出的都是乱码。
ofstream outfile ("AddressBook.txt",ios::out|ios::app);//打开文件
outfile<<name<<" "<<birthYear<<" "<<birthMonth<<" "<<birthDay<<" "<<telnumber<<" "<<email<<'\n';
//name,telnumber,email,为cstring型,birthYear,birthMonth,birthDay,为int型
作者: mummymyth 发布时间: 2011-12-02
             你是不是编译的时候 的 字符集 是 unicode的 ??            
            作者: dhbfly 发布时间: 2011-12-02
             那你就把CString转为string
你挑着用:
CString strSrc("123");
CStringA strSrcA(strSrc);
CStringW strSrcW(strSrc);
const char* p1 = strSrcA;
const WCHAR* p2 = strSrcW;
string strDesA((LPCSTR)strSrcA);
wstring strDesW((LPCWSTR)strSrcW);
            你挑着用:
CString strSrc("123");
CStringA strSrcA(strSrc);
CStringW strSrcW(strSrc);
const char* p1 = strSrcA;
const WCHAR* p2 = strSrcW;
string strDesA((LPCSTR)strSrcA);
wstring strDesW((LPCWSTR)strSrcW);
作者: lgstudyvc 发布时间: 2011-12-02
  引用 1 楼 dhbfly 的回复:
  
你是不是编译的时候 的 字符集 是 unicode的 ??
你是不是编译的时候 的 字符集 是 unicode的 ??
我在项目属性里改成了多字节字符集,再试还是乱码
作者: mummymyth 发布时间: 2011-12-02
  引用 2 楼 lgstudyvc 的回复:
  
那你就把CString转为string
  
你挑着用:
  
CString strSrc("123");
  
CStringA strSrcA(strSrc);
CStringW strSrcW(strSrc);
  
const char* p1 = strSrcA;
const WCHAR* p2 = strSrcW;
  
string strDesA((LPCSTR)strSr……
那你就把CString转为string
你挑着用:
CString strSrc("123");
CStringA strSrcA(strSrc);
CStringW strSrcW(strSrc);
const char* p1 = strSrcA;
const WCHAR* p2 = strSrcW;
string strDesA((LPCSTR)strSr……
转成string也还是乱码
作者: mummymyth 发布时间: 2011-12-02
 相关阅读 更多  
      
    热门阅读
-  
 office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
          阅读:74
 -  
 如何安装mysql8.0
          阅读:31
 -  
 Word快速设置标题样式步骤详解
          阅读:28
 -  
 20+道必知必会的Vue面试题(附答案解析)
          阅读:37
 -  
 HTML如何制作表单
          阅读:22
 -  
 百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
          阅读:31
 -  
 ET文件格式和XLS格式文件之间如何转化?
          阅读:24
 -  
 react和vue的区别及优缺点是什么
          阅读:121
 -  
 支付宝人脸识别如何关闭?
          阅读:21
 -  
 腾讯微云怎么修改照片或视频备份路径?
          阅读:28
 















