定义字符数组:
方法1:char *temp = new char[256] , *ch = new char[256], *num = new char[10];
方法2:char temp[80];
相互转换:
字符串到数组( CString→char[ ] )
CString strTemp = "nihao" ;
char charTemp[50];
strcpy(charTemp,strTemp ); //不用考虑长度的问题
字符串检索:
CString::ReverseFind()与CString ::Find()的区别
1、CString::Find,函数名称,返回此CString对象中与需要的子字符串或字符匹配的第一个字符的从零开始的索引;如果没有找到子字符串或字符则返回-1。
2、ReverseFind(),在一个较大的字符串中从末端开始查找某个字符
CString::ReverseFind int ReverseFind( TCHAR ch ) const;
返回值:返回此CString对象中与要求的字符匹配的最后一个字符的索引;如果没有找到需要的字符则返回-1。
CString str = "abcdb";
int x1 = str.Find('b');
x1 = 1;
int x2 = str.ReverseFind('b');
x2 = 4;