strstr , strcasestr , strnstr - locate a substring in a string
Lb libc
The
strcasestr ();
function is similar to
strstr (,);
but ignores the case of both strings.
The
strnstr ();
function
locates the first occurrence of the null-terminated string
Fa little
in the string
Fa big ,
where not more than
Fa len
characters are searched.
Characters that appear after a
`\0'
character are not searched.
Since the
strnstr ();
function is a
Fx specific API, it should only be used when portability is not a concern.
const char *largestring = "Foo Bar Baz"; const char *smallstring = "Bar"; char *ptr; ptr = strstr(largestring, smallstring);
The following sets the pointer ptr to NULL because only the first 4 characters of largestring are searched:
const char *largestring = "Foo Bar Baz"; const char *smallstring = "Bar"; char *ptr; ptr = strnstr(largestring, smallstring, 4);
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |