假如有CString Cstr1= "我们的";
Cstr2 = "as我们的";
Cstr3 = "11我的的";
Cstr4 = "@~%^$&wn我们的";
现在我想实现当字符串中为字母和数字才合法返回TURE,否者返回FALSE;
我现在实现的方法如下
BOOL HasChineseChar(CString Cstr)
{
int nLen = Cstr.GetLength();
unsigned char ch1, ch2;
for(int i = 0; i != nLen; ++i)
{
ch1 = Cstr[i];
ch2 = Cstr[i+1];
if (ch1 < 0xA0)
{
return TRUE;
}
else
{
return FALSE;
}
}
return FALSE;}
只能判定出以下情况(中文XXX中文)(中文XXXX)(中文XXXX)的情况啊 大侠们帮帮忙
Cstr2 = "as我们的";
Cstr3 = "11我的的";
Cstr4 = "@~%^$&wn我们的";
现在我想实现当字符串中为字母和数字才合法返回TURE,否者返回FALSE;
我现在实现的方法如下
BOOL HasChineseChar(CString Cstr)
{
int nLen = Cstr.GetLength();
unsigned char ch1, ch2;
for(int i = 0; i != nLen; ++i)
{
ch1 = Cstr[i];
ch2 = Cstr[i+1];
if (ch1 < 0xA0)
{
return TRUE;
}
else
{
return FALSE;
}
}
return FALSE;}
只能判定出以下情况(中文XXX中文)(中文XXXX)(中文XXXX)的情况啊 大侠们帮帮忙
{
ch1 = Cstr[i];
ch2 = Cstr[i+1];
if (ch1 < 0xA0)
{
return TRUE;
}
else
{
return FALSE;
}
}
return FALSE;
你只拿了前面的两个字节来判断而已
把后面所有的内容都丢掉了!
BOOL HasChineseChar(CString Cstr)
{
int nLen = Cstr.GetLength();
unsigned char ch1, ch2;
for(int i = 0; i != nLen; ++i)
{
ch1 = Cstr[i];
if (ch1 >= 0xA0)
{
return TRUE;
}
else
{
continue;
}
}
return FALSE;
}
一个函数遇到return语句之后,就返回了,不再往下执行,要不然你就自己调试看看吧if (ch1 < 0xA0)
{
return TRUE;
}
else
{
return FALSE;
}当i为0时,要么返回true要么返回false,然后这个函数就结束了!