用C++的实现一个功能:有一个字符串“woshiCKHya”,然后我想判断这个字符串是否有连续的“CKH”字符,有的话就为真,
没有就为假如何实现呢?
使用string.h中的strstr,代码如下:
void Test1()
{
char *a = "woshiCKHya";
char *b = "CKH";
int c = 0;
char * Recive_Address = strstr(a,b);
if(Recive_Address)
c = 1;
else {
c = 0;
}
qDebug() << c << endl;
}