#include <string>
#include <iostream>
using namespace std;
int first(unsigned char ch)
{
if(ch >= 0xb0 && ch <= 0xf7)
return 1;
else
return 0;
}
int second(unsigned char ch)
{
if(ch >= 0xa1 && ch <= 0xfe)
return 1;
else
return 0;
}
void check(char* p)
{
unsigned int i;
int num = 0;
string str;
for(i = 0; i < strlen(p) - 1; i++)
{
if(first(p[i]) && second(p[i+1]))
num++;
}
if(i == strlen(p))
cout<<"该字符串中没有中国汉字!"<<endl;
else
cout<<"该字符串中有"<<num<<"个中国汉字!"<<endl;
}
int main()
{
char* str= "sdf国ddfsd中";
check(str);
return 0;
}