c++中没有find函数
时间: 2023-12-16 07:05:53 浏览: 63
,但可以使用字符串库中的strstr函数来查找某个子字符串在另一个字符串中的位置。例如:
```c
#include <stdio.h>
#include <string.h>
int main() {
char str[] = "Hello World!";
char *substr = "World";
char *pos = strstr(str, substr);
if (pos != NULL) {
printf("'%s' is found at position %ld\n", substr, pos - str);
} else {
printf("'%s' is not found\n", substr);
}
return 0;
}
```
输出:
```
'World' is found at position 6
```
阅读全文