How to remove a character in string

closed account (365X92yv)
How do you take the first character in a string, remove it, shifting the whole string down one spot, and then appending the character you removed to the end of the string?
1
2
3
4
5
6
7
8
9
10
11
12
#include <iostream>
#include <string>
using namespace std;
int main()
{
  string s;
  cout << "Enter string: ";
  cin >> s;
  s = s.substr(1).append(s.substr(0,1));
  cout << s << endl;
  return 0;
}
./a.out
Enter string: 0123456789
1234567890

histrungalot, how do you match the output box to a code box?
What do you mean? I don't understand what you are asking.
He means how did you get that box on the right with this in it:

./a.out
Enter string: 0123456789
1234567890


To go horizontally adjacent to the box with this in it:
1
2
3
4
5
6
7
8
9
10
11
12
#include <iostream>
#include <string>
using namespace std;
int main()
{
  string s;
  cout << "Enter string: ";
  cin >> s;
  s = s.substr(1).append(s.substr(0,1));
  cout << s << endl;
  return 0;
}
Oh. I found it by accident.

[ code ]
Past code
---
Output
[ /code ]

It looks like the magic number of "-" is 3.

EDIT: Remove the text one
Last edited on
Topic archived. No new replies allowed.