在Console工程中引用CString
来源:互联网 发布:纸箱设计软件 编辑:程序博客网 时间:2024/06/06 17:18
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;
}
#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;
}
PS:dll或者lib的工程,由于afx.h默认带了一个DllMain,致使要使用CString类需要几个步骤。
具体的步骤请参见:在非MFC程序中引用CString
0 0
- 在Console工程中引用CString
- 在Console工程中引用CString
- 在Console工程中引用CString
- 在Console项目中显示CString对象的问题
- 如何在Console程序中使用MFC类(例如CString)
- Tips:在控制台(Console)中调用CFile、CString等
- 在非MFC程序中引用CString
- 在非MFC程序中引用CString
- 在非MFC程序中引用CString
- 在非MFC程序中引用CString
- 在非MFC程序中引用CString
- 在非MFC程序中引用CString
- 在非MFC程序中引用CString
- 在非MFC程序中引用CString
- 在非MFC程序中引用CString
- 在非MFC程序中引用CString
- 在非MFC程序中引用CString
- 在一个工程中引用另一个工程
- mysql学习--基本使用
- hdu1166树状数组||线段树。。
- MFC创建模态对话框与非模态对话框 DoModal Invalidate
- poj1129 Channel Allocation
- 16GB内存神奇玩法大全
- 在Console工程中引用CString
- 新闻滚动代码
- 区分重载(overload),覆盖(Override)和隐藏(hide)
- ASIHTTPRequest的使用——框架使用
- class文件的(解析)执行过程
- 静态查找表的顺序存储结构
- 黑马程序员--学习笔记(集合)
- 隐藏进程
- gnome 3