Cards (11)

  • A string is a sequence of characters. It is used to store text or characters.
  • A string is a sequence of characters. It is used to store text or characters.
  • A C++ string library provides a powerful and convenient way to work with a sequences of characters.
  • A C++ string library provides a powerful and convenient way to work with a sequences of characters.
  • The string library offers multiple methods/functions to manipulate strings, like concatenation, searching, extraction and modification.
  • The string library offers multiple methods/functions to manipulate strings, like concatenation, searching, extraction and modification.
  • The string library offers multiple methods/functions to manipulate strings, like concatenation, searching, extraction and modification.
  • To use a string, it should be included in the header file section, using the syntax below:
    #include <string>
  • String Declaration & Initialization
    To declare a string, use the syntax below:
    string str1; // empty string
    string str2 = "Hello"; // with initialization
    string str3("World"); // another way to initialize
    string str4(str2); // to copy
    string str5(5, 'a'); // initialize 5 'a' characters
    string str6(""); // empty string
  • String Declaration & Initialization
    To declare a string, use the syntax below:
    string str1; // empty string
    string str2 = "Hello"; // with initialization
    string str3("World"); // another way to initialize
    string str4(str2); // to copy
    string str5(5, 'a'); // initialize 5 'a' characters
    string str6(""); // empty string
  • String Declaration & Initialization
    To declare a string, use the syntax below:
    string str1; // empty string
    string str2 = "Hello"; // with initialization
    string str3("World"); // another way to initialize
    string str4(str2); // to copy
    string str5(5, 'a'); // initialize 5 'a' characters
    string str6(""); // empty string