take pieces of a string in c 2b 2b

Solutions on MaxInterview for take pieces of a string in c 2b 2b by the best coders in the world

showing results for - "take pieces of a string in c 2b 2b"
Giovanni
04 Oct 2018
1#include <iostream>
2#include <string.h>
3
4using namespace std;
5int main() {
6   string str1 = "Apples are red";
7   string str2 = str1.substr(11, 3);
8   string str3 = str1.substr(0, 6);
9
10   cout << "Substring starting at position 11 and length 3 is: " << str2 <<endl;
11   cout << "Substring starting at position 0 and length 6 is: " << str3;
12   return 0;
13}