CString类 使用编译错误

来源:百度知道 编辑:UC知道 时间:2024/07/04 11:35:28
#include <iostream.h>
#include <afx.h>

int main()
{
CString cs;
cout << sizeof(cs) << endl;
cs.Format("%s\n","My name is YouZhonghui");
cout << sizeof(cs) << endl;
return 0;
}

编译过了 运行的时候 提示没定义_beginthreadex 我在
project -> setting -> c\c++ -> code generation 里设置了 multithread dll

这个问题解决了 但是运行时冒出其他错误
LINK : warning LNK4098: defaultlib "MSVCRT" conflicts with use of other libs; use /NODEFAULTLIB:library
nafxcwd.lib(timecore.obj) : error LNK2001: unresolved external symbol __mbctype
nafxcwd.lib(apphelp.obj) : error LNK2001: unresolved external symbol __mbctype
nafxcwd.lib(filelist.obj) : error LNK2001: unresolved external symbol __mbctype
nafxcwd.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argv
nafxcwd.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argc
Debu

简单点说的话,如果要在console下使用MFC,在新建工程的时候选择an application that support MFC选项。

复杂的说,就是没有配置好。

CString的size永远是4,因为它是一个包含char*的类。

CString你用的是MFC的吧?在控制台下不好用。
推荐用STL的string

Project(工程) -> Settings(设置) 右边第一个选项卡里选择Use MFC As Static Library.