Advertisement
tanjirantu

string_101

Mar 31st, 2023
932
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.08 KB | Source Code | 0 0
  1. #include<iostream>
  2. #include<string>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     string str;
  8.     // Take input string containing spaces
  9.     //getline(cin, str);
  10.     //cout << str << endl;
  11.  
  12.     string s1 = "A quick brown fox"; // lexical values: 65+32+113+117+105+99+107+32+98+114+111+110+32+102+111+120
  13.     string s2 = " over the lazy dog";
  14.     string s3 = "abcdefgh abcdefgh abcedfgh"; // lexical values: 97+98+99+100+101+102+103+104+32+97+98+99+100+101+102+103+104+3297+98+99+100+101+102+103+104
  15.     //s1.append(s2); // s1 + s2
  16.     //s1.clear(); // will clear the string
  17.  
  18.     //s3.erase(0, 7);
  19.     //cout << s3 << endl;
  20.     //cout << s1.compare(s3) << endl;
  21.  
  22.     //cout << s2.find("u");
  23.  
  24.     //s2.insert(0, "jumps");
  25.     //cout << s2.length() << " " << s2.size() << endl;
  26.  
  27.  
  28.     //string s = s2.substr(1, 5);
  29.     //cout << s << endl;
  30.  
  31.     // Convert a numeric String to Int
  32.     //string numericString = "786";
  33.     //int x = stoi(numericString);
  34.  
  35.  
  36.     // Convert a Int to String
  37.     int x = 786;
  38.     string s = to_string(x);
  39.  
  40.     cout << s << endl;
  41.     return 0;
  42. }
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement