function
- Annotate each line of the following code including what each built-in function does.
#include <iostream>
#include <string>
using namespace std;
int main() {
string woo = “”;
string s1 = "who's woods these are I think I know ";
s1 += " his house in in the village low.";
cout << s1 << " " << s1.length() << endl << endl;
cout << s1.at(10) << endl;
cout << s1.substr(10, 6);
s1.insert(10, "hi there");
cout << s1 << endl;
s1.erase(5, 6);
cout << s1 << endl;
woo = s1.substr(0, s1.find(" "));
s1.clear();
cout << s1 << endl;
cout << s1.empty() << endl;
cout << woo << endl;
return 0;
}
Trending now
This is a popular solution!
Step by step
Solved in 2 steps