三亩地 三亩地SAN MU DI · CODE DIARY
ARTICLE DETAIL

日记详情

真实记录编程学习的某一天,欢迎挑你感兴趣的翻一翻。

比较长的字符串中,是否含有特定字符串_repeat

比较长的字符串中,是否含有特定字符串_repeat

比较长的字符串中,是否含有特定字符串_repeat

#include <string.h> const char *long_str = "This is a very long string containing some keywords"; const char *needle = "keywords"; if (strstr(long_str, needle) != NULL) { // 存在 "keywords"字符串 printf("found it\n"); } else { // 不存在 "keywords"字符串 printf("not found\n"); }
← 返回列表