找到以另一种文本的文本 [英] Find the text starting with another text
问题描述
有没有任何方法 C
可以找到其他文本中的文本?
例如,文本=abaHello
, textneedtoSearch =你好;
如果在文本
包含你好
,返回true,否则返回false
。
`字符*的strstr(为const char * S1,为const char * S2)`
指针返回到所述第一
在S1字符串s2的实例。返回
一个空指针s2也不
在S1遇到的。
块引用>在additon,
INT STRCMP(为const char * S1,为const char * S2);
STRCMP
S1的字符串s2字符串进行比较。该函数将返回0,如果它们是相同的,包括数字下; 0若S1< S2,一些> 0,如果S1> S2。
这是最常用的
的字符串处理函数。
块引用>和检查此链接,获取有关C字符串函数, C字符串函数 什么p>
Is there any method in
C
can find a text within another text?For example,
text = "abaHello"
,textneedtoSearch = "Hello";
.If the
text
contains"Hello"
,return true, else return false
.解决方案Character and string searching functions
`char *strstr( const char *s1, const char *s2)`
returns a pointer to the first instance of string s2 in s1. Returns a NULL pointer if s2 is not encountered in s1.
In additon,
int strcmp(const char *s1, const char *s2);
strcmp
compares the string s1 to the string s2. The function returns 0 if they are the same, a number < 0 if s1 < s2, a number > 0 if s1 > s2.This is one of the most commonly used of the string-handling functions.
And check this link for anything about string functions in C, C string functions
这篇关于找到以另一种文本的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!