关于CString和string相关的数据类型转换 50分 我要在win32下使用CString,应该包含什么头文件另外string有没有办法把double float int 等其他类型的转换为string 或者char* 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 使用C中的转换函数呀.atoi,itoa....等等. 将其他类型转换到string ,需要使用C函数的类型转换库CString需要包含 Afx.h该类是MFC的东西 不行啊!错误提示如下:fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include <windows.h> #include "stdafx.h"在stdafx.h中://#include <windows.h>#include <afx.h> 你的工程可能不是支持MFC的,最简单的做法是重建一个使用MFC的project,然后复制代码。也可以着一个MFC的project例子,将他的stdafx.h替换现在的stdafx.h include "string.h"sring t,t.format("%d,%f",1,1.01);try it! MFC工程不需要包含什么,直接使用CString. include "string.h"sring t,t.format("%d,%f",1,1.01);try it!瞎说吧 你的工程可能不是支持MFC的,最简单的做法是重建一个使用MFC的project,然后复制代码。也可以着一个MFC的project例子,将他的stdafx.h替换现在的stdafx.h**********不是不支持,而是他的根本就是mfc的,==》MFC apps must not #include <windows.h>在mfc下是不能再包含windows.h的。直接可以使用CString的了。 http://blog.csdn.net/horisly/articles/378796.aspx对论坛中有关数据类型转换的总结 楼上的各位都说的很清楚了。1 在VC中只要#include <afx.h>(而不是string.h)就可以用CString对象了,除非楼主的工程不支持MFC(解决方法见orbit(走了走了) 的答复)。2 数据类型转换(转换时要用到string.h了): int,long-->string CString str; str.Format("%d",此处用你的int或long变量代替); char*--->string CString str; char* s="My string."; str=s string--->char* CString str; str="My string."; char* s=new char[100]; strcpy(s,str);另外:To: orbit(走了走了) 怎样才能看到MFC系统函数如GetAsSystemTime的源代码,我用F12键只能看到它们的函数原型。呵呵,不好意思!在另外一个问题贴中也问了这个问题,现在又追到这里来问了,请指点一下小弟呀! vector 中放如cobject的派生类报错 AbortProc中的PeekMessage有什么用处? 看过深入浅出mfc的进来,问个问题 请问ZIP是没有版权的吗,可以免费使用和发布吗,谢谢! 很急,关于列表框和编辑框的问题 我想做关于旅游的短信服务查询,应该怎么着手,哪位兄弟可以给我提个建议呢? send函数老是返回10014 vc下载 VC APPWizard 中第6步,将view的基类选为CScrollView后,必须要多虚拟键进行处理吗? 我想去北京,资格够吗? 怎样让VC中的类视图中的类显示 怎么将一个工程中的部分资源在另一工程中使用?
CString需要包含 Afx.h
该类是MFC的东西
错误提示如下:
fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include <windows.h>
//#include <windows.h>
#include <afx.h>
sring t,
t.format("%d,%f",1,1.01);
try it!
sring t,
t.format("%d,%f",1,1.01);
try it!
瞎说吧
**********
不是不支持,而是他的根本就是mfc的,
==》
MFC apps must not #include <windows.h>
在mfc下是不能再包含windows.h的。直接可以使用CString的了。
对论坛中有关数据类型转换的总结
1 在VC中只要#include <afx.h>(而不是string.h)就可以用CString对象了,除非楼主的工程不支持MFC(解决方法见orbit(走了走了) 的答复)。
2 数据类型转换(转换时要用到string.h了):
int,long-->string
CString str;
str.Format("%d",此处用你的int或long变量代替);
char*--->string
CString str;
char* s="My string.";
str=s
string--->char*
CString str;
str="My string.";
char* s=new char[100];
strcpy(s,str);另外:
To: orbit(走了走了)
怎样才能看到MFC系统函数如GetAsSystemTime的源代码,我用F12键只能看到它们的函数原型。
呵呵,不好意思!在另外一个问题贴中也问了这个问题,现在又追到这里来问了,请指点一下小弟呀!