Rather than messing about with hand rolled loops why not try the magic of the standard C++ library?
-
std::random_shuffle
can give you a random vector of capital letters:
const char letters[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
std::vector<char> stirred( letters, letters + 26 );
std::random_shuffle( stirred.begin(), stirred.end() );</char>
-
std::partition
can give you greater than 'M' stuff:
bool less_than_M( char c )
{
return c < 'M';
}
std::partition( stirred.begin(), stirred.end(), less_than_M );
You really don't want to fiddle about with low level stuff like pointers and arrays when there are better ways of representing your data and doing the operations you want.
Cheers,
Ash
Edited as I got the sign in less_than_M the wrong way 'round, complete spanner that I am...