Strchr, wcschr, strrchr, wcsrchr, _ tcschr, _ tcsrchr Function
(1)
Char * strchr (const char*String,Int C );Wchar_t*Wcschr (const wchar_t*String,Wchar_t C );Find a character in a string.Searches for the specified character that appears for the first
C strchr function example
Prototype: char * strchr (const char * s, char c );
# Include
Searches for the position where character c appears for the first time in string s, and returns the pointer to the position where character c appears for
Header files: #include STRCHR () is used to find the first occurrence of a character in a string, and its prototype is:char * STRCHR (const char *STR, int c);"Parameter" STR is the string to find, and C is the character to look for.STRCHR () will
Strchrdefined in header file Char *strchr (const char *STR, int ch);look for the first occurrence of CH (converted to char as (char) ch) in the null-terminated byte string pointed to by STR (each character is considered to be a unsigned char). The
Function prototype: char * strchr (const char * STR, char ch );
Return Value: returns a pointer pointing to the position where the character ch appears for the first time. If no ch is found in STR, null is returned.
Parameter description:
STR:
PHP strchr () function example tutorial
Definition and usageThis strchr () function searches for a series of other internal strings for the first time.This function returns the remaining strings (from the matching point), or FALSE if this string is
To differentiate by the definition of a function:
1.STRSTR:
Char *strstr (const char *haystack, const char *needle)
As can be seen, the STRSTR function searches for a const char* type of data, the string constant
2.STRCHR:
Char *strchr
Finding another string in a string can use either Strstr (), STRCHR (), STRRCHR (), STRISTR () four functions.
The function strstr () is the most common, and the function prototype is:
Strstr (String,search,before_search)//string the string to be
In a longer string this finds matching strings or characters, where STRSTR () and STRCHR () are exactly the same.Cases:echo strstr (' Why all you ', ' you ');Output:YouIf you are:echo strstr (' Why all you ', ' you ');Then no outputThe Stristr ()
The simulation implements the STRCHR function, function: Finds a character in a string where the first occurrence occurs, if no return null#include #include char const* MY_STRCHR (char const *p,char c) {assert (P! = NULL), while (*p) {if (*p = = c)
Search for a character from a string and return the pointer to the first match,
The first write may be like this:
Char * strchr (const char * STR, char c) { assert (STR! = NULL); while (* STR & * STR ++! = C); If (* Str) return (char *) STR;
Implement STRCHR (Find a character in a string, find a pointer to that character, return null if not found) #include #include char * MY_STRCHR ( Char Const *STR, char c) {assert (str! = NULL), while (*str! = ')} {if (*str = = c) return str;elsestr++
Char *strchr (const char *s, int c)Function: Find the position of the first C character in the string s
Description: Returns a pointer to the position of the first occurrence of C, the returned address is the first pointer to the string that is
Recently, this function is used to construct a binary tree based on the forward and middle orders, but this function is not good because strchr returns a character in the string.First timeIf there are repeated characters, it will be white blind.
Strcat
A simple strcat, I in the actual coding, or found the problem, first list
1. Mainly in Strcat_m, the beginning of Line8,while (tmp++!= ' ") and the following line9 is not the same.
Line8: After TMP points to ' "," and then shift back to a
/* Strchr */ /* This function is used to locate the first occurrence of a character in a string. */ /* If it is found, the absolute address is returned. If it is not found, null is returned. */ Char * /* Returns the absolute position of
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.