Common C ++ string processing functions and examples-general Linux technology-Linux programming and kernel information. For more information, see the following. Char * strcpy (char * s1, const char * s2)
Copy string s2 to string array s1 and return the value of s1.
Char * strncpy (char * s1, const char * s2, size_t n)
Copy up to n characters in string s2 to string array s1 and return the value of s1.
Char * strcat (char * s1, const char * s2)
Add string s2 to the end of string s1. The first character of s2 redefines the null terminator of s1. Returns the value of s1.
Char * strncat (char * s1, const char * s2, size_t n)
Add up to n characters in string s2 to the end of string s1. The first character of s2 redefines the null terminator of s1. Returns the value of s1.
Int strcmp (const char * s1, const char * s2)
Compares string s1 and string s2. When s1 is equal to, less than, or greater than s2, the function returns 0, less than 0, or greater than 0.
Int strncmp (const char * s1, const char * s2, size_t n)
Compares n characters in string s1 with string s2. When s1 is equal to, less than, or greater than s2, the function returns 0, less than 0, or greater than 0.
Char * strtok (char * s1, const char * s2)
Use a series of strtok calls to tag the s1 string (the string is divided into logical components, just like every word in a line of text) and separate it with the characters contained in string s2. The first call contains s1 as the first parameter, and the subsequent call continues to mark the same string, including NULL as the first parameter. The current mark pointer is returned for each call. If no more tags are available during function calling, NULL is returned.
Size_t strlen (const char * s)
Returns the number of characters before the null Terminator.
Example:
// The source code is compiled in the Visual c ++ 6.0 environment
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.