CString类常用方法---GetLength(),strlen(),IsEmpty(),Empty()
来源:互联网 发布:数据分析基础 教材 编辑:程序博客网 时间:2024/05/22 04:24
int GetLength( ) const; //得到字符串的字节数(并不都是个数,如汉字一个字占两个字节)
int strlen( const char *string ); //计算参数字符串里面字节的个数并返回
BOOL IsEmpty( ) const; //如果字符串含有字符就返回假,如果是个空字符串就返回真
void Empty( ); //清空字符串,相当于把字符串的值赋为""
注:
在函数后面加 const 的意思是:
如果一个类声明了一个常量对象,这个对象只能使用后边带 const 这个的方法.
例1:
CString a,b,c,d;
a = "123456789";
b = "中国人";
c = "中国人12345";
a.GetLength(); //得到9个
b.GetLength(); //得到6个
c.GetLength(); //得到11个
例2:
CString a;
a = "123456789";
if (TRUE == a.IsEmpty()) //如果a为空则把 "null_1" 打印在对话框中
{
MessageBox("null_1");
}
a.Empty(); //把a中的字符串清空
if (TRUE == a.IsEmpty()) //如果a为空则把 "null_2" 打印在对话框中
{
MessageBox("null_2");
}
0 0
- CString类常用方法---GetLength(),strlen(),IsEmpty(),Empty()
- CString类常用方法---GetLength(),strlen(),IsEmpty(),Empty()
- cstring::getlength()
- CString::GetLength
- cstring::getlength()
- cstring.IsEmpty
- cstring.IsEmpty
- cstring.IsEmpty
- CString类常用方法
- CString::GetLength()获得字节数的正确方法
- CString::GetLength()获得字节数的正确方法
- CString::GetLength()获得字节数的正确方法介绍
- CString::GetLength()获得字节数的正确方法
- CString::GetLength()获得字节数的正确方法介绍
- CString::GetLength()获得字节数的正确方法介绍
- java.util.Stack类中 empty() 和 isEmpty() 方法的作用
- CString的GetLength
- 关于Cstring::GetLength()
- dojo表格内容居左、居中和居右
- linux 使用cryptop++安装过程。 问题:Unresolved inclusion “hodes.h”
- django学习系列之模板系统篇(二)
- android和iOS平台的崩溃捕获和收集
- java接口
- CString类常用方法---GetLength(),strlen(),IsEmpty(),Empty()
- (1)今天你求职了吗?
- 如何获取函数调用链
- SQL SERVER 2008 MINI安装
- filter配置
- SRAM和DRAM的区别
- android.os.NetworkOnMainThreadException异常
- IOS开发笔记(5)程序异常crash捕获与拦截
- Restarting nginx daemon: nginxnginx: [emerg] bind() to 0.0.0.0:80 failed (98: