Sort all characters inside the string

// Sort all characters inside a string.cpp : Defines the entry point for the console application.

#include "stdafx.h"
#include "string"
#include "iostream"
#include "algorithm"
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
       const string hello(" Hello, how are you? ");
       string s(hello.begin(),hello.end());
       //Iterate through all of the cahracters
       string::iterator pos;
       for(pos = s.begin(); pos != s.end(); ++pos)
             cout << *pos;
       cout << endl;
       cout << "ordered: " << s << "\n";
       return 0;

Share on Google Plus