String of C ++

Source: Internet
Author: User

# Include <iostream> # include <string> using namespace STD; int main () {string S1 = "hello"; string S2 = "world"; string S3 = S1 + S2; // Add two strings, which are allowed strings S4 = "hello" + "word"; // The cout is not allowed <S3 <Endl; // correct cout <S4 <Endl; // The cout is incorrect <"hello" + "world" <Endl; // The cout is incorrect <S1 + "world" <Endl; // correct} // a sentence, connected to the string literal value, at least one is of the string type. The string: size_type type is used to receive the size () value returned by the string. The string subscript starts from 0 to string: size ()-1 # include <iostream> using namespace STD; int main () {string S = "hello"; for (string: size_type I = 0; I <S. size (); I ++) {cout <s [I] ;}cout <Endl; return 0 ;}

String in C ++ can be usedC Language(Cctype header)TextProvided functions.

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.