C ++ string, string

Source: Internet
Author: User

C ++ string, string

C ++ string:
1. character array: Use the null character '\ 0' to terminate the string char greeting [6] = {'h', 'E', 'l', 'l', 'O ', '\ 0'}; or char greeting [] = "Hello ";
Function operation:
1 strcpy (s1, s2); copy string s2 to string s1.
2 strcat (s1, s2); connects string s2 to the end of string s1.
3 strlen (s1); returns the length of string s1.
4 strcmp (s1, s2); If s1 and s2 are the same, 0 is returned; If s1 <s2, the return value is smaller than 0; If s1> s2, the return value is greater than 0.
5 strchr (s1, ch); returns a pointer pointing to the first occurrence of the character ch in string s1.
6 strstr (s1, s2); returns a pointer pointing to the first position of string s2 in string s1.
2. String class: Standard Library header file <string>
Function operation:
1str2 = str1; copy string s2 to string s1.
2str3 = str1 + str2; connect string s2 to the end of string s1.
3str1. size (); returns the length of string s1.
4 str1.append () add characters to the end of the string
5str1. find () Search for strings in strings
6 str1.insert () insert characters
7 str1.length () returns the length of the string.
8 str1.replace () replacement string
9 str1.substr () returns a substring.
10...

Related Article

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.