You can do what you want very easily with the C++ Standard Template Library:
Code:#include<iostream> #include<string> begin(), end() #include<algorithm> //random_shuffle() #include<ctime> //time() using namespace std; int main() { srand(time(0)); //shuffle the whole string: string str = "hello"; random_shuffle(str.begin(), str.end()); cout<<str<<endl; //shuffle part of the string: str = "hello world"; random_shuffle(&str[6], str.end()); //only shuffles 'world' cout<<str<<endl; return 0; }