CJCoding With Joseph
15free / daySign inCreate account
โ† Back to Question List
C++ Code Walkthrough #18

String Substr and Find

mediumPrinting

๐Ÿ“„ Code

Read carefully โ€” what does this print?
1#include <iostream>
2#include <string>
3using namespace std;
4 
5int main() {
6 string s = "programming";
7 cout << s.substr(0, 7) << endl;
8 cout << s.substr(7) << endl;
9 cout << s.find("gram") << endl;
10 cout << s.length() << endl;
11 return 0;
12}

๐ŸŽฏ Your Answer