Answers for "access part of string in c++"

C++
0

access part of string in c++

#include <iostream>
#include <string.h>

using namespace std;
int main() {
   string str1 = "Apples are red";
   string str2 = str1.substr(11, 3);
   string str3 = str1.substr(0, 6);

   cout << "Substring starting at position 11 and length 3 is: " << str2 <<endl;
   cout << "Substring starting at position 0 and length 6 is: " << str3;
   return 0;
}
Posted by: Guest on July-03-2021

Code answers related to "access part of string in c++"

Browse Popular Code Answers by Language