A/C + + string lookup Function < go >

Source: Internet
Author: User

A/C + + string library (string. h) provides several string lookup functions, as follows: MEMCHR locates the given character in the specified memory STRCHR the given character in the specified string strcspn returns the number of characters found before any one of the characters in the string str2 is located in the string str1 STRRCHR position the last occurrence of a given character in a string strpbrk in the string str1 the first occurrence of any character in a string str2 strspn returns the string str1 the number of characters from the start character to the first one that is not in str2 strstr Locate the string str2 the first occurrence of the position function description in the string str1:1, MEMCHR Prototypes:Const void* MEMCHR (Const void* PTR,intvalue, size_t num); void* MEMCHR (void* PTR,intValue , size_t num); parameter: PTR, the memory pointer to be looked up, value to find, num, memory size. Description: Finds value in the memory pointed to by PTR, returns a pointer to the element that first matches the value, and returns a null pointer if it is not found. 2, STRCHR Prototypes:Const Char* STRCHR (Const Char* STR,intcharacter); Char* STRCHR (Char* STR,intcharacter); parameter: str, string pointer to be found; character, the value to find. Description: Finds character in the string str, returns a pointer to the element that first matches the character, and returns a null pointer if it is not found. 3, STRCSPN prototype: size_t strcspn (Const Char* STR1,Const Char*str2); parameter: str1, string pointer to find, STR2, string pointer to find. Description: Finds the characters in the str2 in str1 and returns the number of characters that were found when any of the characters in the str2 were located. 4, STRRCHR Prototypes:Const Char* STRRCHR (Const Char* STR,intcharacter); Char* STRRCHR (Char* STR,intcharacter); parameter: str, the string pointer to be searched; character, the value to find. Description: Finds character in Str, returns a pointer to the element that was last matched to character, and returns a null pointer if not found. 5, STRPBRK Prototypes:Const Char* STRPBRK (Const Char* STR1,Const Char*str2); Char* STRPBRK (Char* STR1,Const Char*str2); parameter: finds any character in the str2 in str1, returns a pointer to an element that matches any character in the first occurrence of str2, or returns a null pointer if not found. 6, STRSPN prototype: size_t strspn (Const Char* STR1,Const Char*str2); parameter: str1, string pointer to find, STR2, string pointer to find. Description: Returns the number of characters from the beginning of the first character of STR1 until a character that is not in str2 appears. 7, Strstr Prototypes:Const Char* STRSTR (Const Char* STR1, cosntChar*str2); Char* STRSTR (Char* STR1,Const Char*str2); parameter: str1, string pointer to find, STR2, string pointer to find. Description: Finds a substring in str1 that matches the str2 and returns the first element pointer to the first match. If not found, returns a null pointer. 

http://blog.csdn.net/isgray/article/details/6853700

A/C + + string lookup Function < go >

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.