Felanpro

Some Basic String Operations

Nov 3rd, 2015
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.06 KB | None | 0 0
  1. /*String Operations
  2.     string x = "Hello";
  3.     int length = x.size();
  4.                                //Prints the length of the word "Hello" in numbers/digits.
  5.     cout << length;
  6.     system("pause");
  7.     */
  8.    
  9.     /*String Operations
  10.     string x = "Hello";
  11.     char firstCharacterVariable = x.at(4);
  12.                                                   //Prints the character depending on what number is typed in char firstCharacterVariable.
  13.                                                   //In this case (4) will print the character "o" of Hello.
  14.                                                   //Think like this: "H e l l o"
  15.                                                   //                  0 1 2 3 4    , always start with 0.
  16.     cout << firstCharacterVariable << endl;
  17.     system("pause");
  18.     */
  19.    
  20.     /*String Operations
  21.     string x = "Hello";
  22.     int length = x.length();
  23.                                 //Also prints the length of the word "Hello" in numbers/digits as well does x.size.
  24.     cout << length << endl;
  25.     system("pause");
  26.     */
Advertisement
Add Comment
Please, Sign In to add comment