how to use a string as an iterator

How could you use a string as an iterator so you can do this...

1
2
string s = "aksdfjsdfnxdujser";
sort(s, s+s.length());


I would think to convert them to c-strings, which i think would work but i dont know how... i know the string member c_str() but thats const char*
{EDIT}

string::iterator

but still this code will not work

1
2
string s = "Hello\\n";
replace(s.begin(), s.end(), "\\n", "\n");


ERROR:
no matching function for call to `replace(__gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, const char[3], const char[2])'
Last edited on
What exactly are you trying to do?
OMG... sorry string has its own implementation of replace()... wow... i was trying to use the STL one thinkin I was all cool... sorry.
Topic archived. No new replies allowed.