Basic String Manipulation

The user will enter a string with a length of at least 5 characters. Next, the user will input an integer representing the starting index of a new sub-string of the original. The final integer will be the length of the new sub-string.

You will then print out the new string taken from the original.


I am kind of stuck and dont really know what to do anymore. All help is appreciated.




#include <iostream>
#include <string>

using namespace std;

int main()
{
string s;
cin >> s;

cout << s.substr(4,6);




return 0;
}
Last edited on
Next, the user will input an integer representing the starting index of a new sub-string of the original.

You still need to implement this part.
the user will input an integer representing the starting index of a new sub-string of the original.


Ask the user to input the starting index and use the function substr to form a sub-string starting from the initial index.
Topic archived. No new replies allowed.