CString函数的库问题

hb2005 2005-04-24 05:44:02
CString是那个库函数下面的函数,我用了

#include "stdafx.h"

int main(int argc, char* argv[])
{
//strMsg = new CString("1234567890", 20);
CString newwww;
printf("Hello World!\n");
return 0;
}

这样提示undeclared identifier
...全文
130 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhongwei5695 2005-04-24
  • 打赏
  • 举报
回复
#include <iostream>
#include <cstring>
using namespace std;

int main()
{
string newwwwww;
printf("Hello World!\n");

return 0;
}
ysbcg 2005-04-24
  • 打赏
  • 举报
回复
#include <string>
using namespace std;
useresu 2005-04-24
  • 打赏
  • 举报
回复
#include "stdafx.h"




#include <string>
using namespace std;

int main(int argc, char* argv[])
{

string newwww;
printf("Hello World!\n");
return 0;
}
chunhai12 2005-04-24
  • 打赏
  • 举报
回复
#include <string>
using namespace std;

int main(
{
string str;
return 0;
}
hb2005 2005-04-24
  • 打赏
  • 举报
回复
还是那样的提示
hb2005 2005-04-24
  • 打赏
  • 举报
回复
#include "stdafx.h"

#include <string.h>


int main(int argc, char* argv[])
{

string newwww;
printf("Hello World!\n");
return 0;
}

这样还是不行
useresu 2005-04-24
  • 打赏
  • 举报
回复
而且string是stl的东西,
stl是标准库的一部分,
标准的东西自然推荐使用了,
可移置性好,而且string的实现也健壮很多.

当然如果你用大部分用到mfc的程序,还是用CString,
因为太多的函数参数是传CString的,虽然有传char * 的,
但是与string还是得转换.不如直接用CString
chunhai12 2005-04-24
  • 打赏
  • 举报
回复
CString是MFC类库中的字符串
在afx.h中

win32 console mode下就用string
useresu 2005-04-24
  • 打赏
  • 举报
回复
CString 是mfc类库的东西,
如果你不是选择的mfc工程,他是不能用的.

你可以用std::string代替
只要头文件#include <string>
就可以了

64,654

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧