CString 是封装的非常不错的一个类,相比于STL的string,它提供了更加丰富的成员方法。虽然在控制台工程中,string基本已经能够完成需要的功能,但是,如果能够偷懒一下的话 ...
在Console工程中引用CString方法如下:
1. 工程设置: project/setting/General/中,
把not using mfc改为usimg mfc in a shared dll 或者是 use mfc in a static library,均可
2. 工程设置: project/setting/[C/C++]/中
Code Genaration中,选择 多线程库
3. 添加头文件:
#include <afx.h>
//#include <windows.h> //如果有 windows.h, 确保 afx.h 在windows.h前面被包含
代码示例:
#include <iostream>
#include <afx.h>
using namespace std;
//检查CString str 是否完全由数字字符组成
int main()
{
CString temp, str=_T("12345");
LPTSTR t = str.GetBuffer(255);
temp.Format("%ld", _tcstol(str.GetBuffer(255), NULL, 10) );
if (temp.GetLength() == str.GetLength())
cout<<"ALL digital numbers!"<<endl;
return 0;
在Console工程中引用CString方法如下:
1. 工程设置: project/setting/General/中,
把not using mfc改为usimg mfc in a shared dll 或者是 use mfc in a static library,均可
2. 工程设置: project/setting/[C/C++]/中
Code Genaration中,选择 多线程库
3. 添加头文件:
#include <afx.h>
//#include <windows.h> //如果有 windows.h, 确保 afx.h 在windows.h前面被包含
代码示例:
#include <iostream>
#include <afx.h>
using namespace std;
//检查CString str 是否完全由数字字符组成
int main()
{
CString temp, str=_T("12345");
LPTSTR t = str.GetBuffer(255);
temp.Format("%ld", _tcstol(str.GetBuffer(255), NULL, 10) );
if (temp.GetLength() == str.GetLength())
cout<<"ALL digital numbers!"<<endl;
return 0;
}
转自: