copying part of a string?

Okay say I have a string with 6 characters in it. What can I do to copy the first 2 characters into one string the next 2 into another and the last 2 into a third?

So I have
string date = 070805;

I want to split 2 characters into these
string month;
string year;
string day;

I was trying to use:
year = date.substr(0,1);
month = date.substr(2,3);
day = date.substr(4,5);

but it did not work.
Last edited on
1
2
3
4

year = date.substr(0,2);
month = date.substr(2,2);
day = date.substr(4,2);
Oh ok I see it now. I was looking at it as starting character and end character not starting and how far. Thanks I appreciate it
Topic archived. No new replies allowed.