Possible Duplicate:
C++ string.substr() function problem
string s = "0123456789";
cout<<s.substr(0,4)<<endl;
cout<<s.substr(4,7)<<endl;
The output of the above lines of code was pretty unexpected , s.substr(0,4) gave me "0123", s.substr(4,7) gave me "456789" . It was expecting only "456" . Am I missing something here , and is there any alternative to substr function in C++ , which would give me only "456" on the second call.