void permute(string elems, int mid, int end) { static int count; if (mid == end) { cout << ++count << \" : \" << elems << end
This post: http://cplusplus.co.il/2009/11/14/enumerating-permutations/ deals with permuting just about anything, not only strings. The post itself and the comments below are pretty informative and I wouldn't want to copy&paste..