CPP   47

strings arrays2

Guest on 20th April 2022 02:06:00 AM

  1. // For C++ libraries.
  2. #include <iostream>
  3. // Library for strings.
  4. #include<string>
  5.  
  6. using namespace std;
  7.  
  8. int main() {
  9.     string word="Book";
  10.     string word2="airplane";
  11.  
  12.     cout << word << endl;
  13.     word[1]='i';
  14.     word[2]=word[3];
  15.     word[3]='e';
  16.     cout << word << endl;
  17.  
  18.     cout << endl;
  19.  
  20.     cout << word2.substr(0,3) << endl;
  21.  
  22.     return 0;
  23.  
  24. }

Raw Paste


Login or Register to edit or fork this paste. It's free.