Inserting into a string

How does one change the string "6013456" to "601-3456"?
If we're talking about a C++ std::string, use the insert() member.
http://www.cplusplus.com/reference/string/string/insert/

If it's a C string aka array you could use sprintf(), or strncat() I think.
Can you help me out? That's so hard to read. I looked at it before.
I don't see whats so hard. The first parameter to insert() is the position you with to insert at. The second parameter is the text to insert.

1
2
3
4
5
string number = "6013456";

number.insert(4, '-');

cout << number;
It's 3, but thanks =). First help from this forum. =)
Topic archived. No new replies allowed.