Click here to Skip to main content
15,892,059 members

Response to: Random Name Generator

Revision 2
Here's my try:

#include <string>
using namespace std;

int main(int argc, char* argv[])
{
	string name;
	static const int namelen = 15;
	
	static const char* letters[2] = { "bcdfghjklmnpqrstvwxyz", "aeiouy" };
	static const letterlen[2] = { strlen(letters[0]), strlen(letters[1]) };
	
	for (int i=0; i<namelen; i++)
		name += letters[i%2][rand()%letterlen[i%2]];
	name[0] = toupper(name[0]);

	return 0;
}
Posted 13-Aug-09 5:16am by sashoalm.
Tags: , , , , , ,