1. Define functions that return random voewls and random consonants - here's a random vowel function:

char RandomVowel() { const char vowels[] = {'a', 'e', 'i', 'o', 'u'}; // Use rand() to get a number between 0 and RAND_MAX. Dividing // by RAND_MAX+1 gives a number n such that 0 <= n < 1, so // multiplying by the number of characters in vowels gives a random // index into vowels const int index = (int)((double)rand()/(RAND_MAX+1) * sizeof(vowels)); return vowels[index]; }

2. Build up a string using alternating calls to the random vowel and consonant functions - note that I've remembered about the upper case first character!

std::string name; name += (char)toupper(RandomConsonant()); for(int i=1;i<desired-name-length;++i) { if (i%2==1) name += RandomVowel(); else name += RandomConsonant(); }

Obviously the desired name length should be chosen at random as well!