c++中字符串全匹配函数
在C++中,字符串的全匹配可以使用字符串比较函数`strcmp()`来实现。`strcmp()`函数会比较两个字符串中的字符,并返回一个整数值来表示比较结果。
示例代码如下:
```cpp
#include <iostream>字符串复制函数
#include <cstring>
int main() {
    char str1[] = "Hello";
    char str2[] = "Hello";
    char str3[] = "World";
    if (strcmp(str1, str2) == 0) {
        std::cout << "str1 and str2 are equal" << std::endl;
    } else {
        std::cout << "str1 and str2 are not equal" << std::endl;
    }
    if (strcmp(str1, str3) == 0) {
        std::cout << "str1 and str3 are equal" << std::endl;
    } else {
        std::cout << "str1 and str3 are not equal" << std::endl;
    }
    return 0;
}
```
输出结果:
```
str1 and str2 are equal
str1 and str3 are not equal
```
在上述代码中,我们使用`strcmp()`函数对两个字符串进行比较。如果两个字符串相等,则`strcmp()`函数返回0;如果字符串不相等,返回的值会被用来指示哪个字符串在字典排序中应排在另一个字符串之前或之后。