/************************************
* Random name Generator (R.N.G.)
* Copyright Reaper [aka 'O_Mpixlas'](c) 2009
* Modify this at will, but I expect some sort of
* credit if you publish it anywhere...
************************************/
#include "stdafx.h"
#include <iostream>
#include <time.h>
#include <stdlib.h>
using namespace std;
const char namesUpper[] = {
'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
'L',
'M',
'N',
'O',
'P',
'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X',
'Y',
'Z'
};
const char namesLower[] = {
'a',
'a',
'b',
'c',
'd',
'e',
'e',
'f',
'g',
'h',
'i',
'i',
'j',
'k',
'l',
'm',
'n',
'o',
'o',
'p',
'q',
'r',
's',
't',
'u',
'u',
'v',
'w',
'x',
'y',
'z'
};
inline int randomChar(bool uppercase)
{
int random = rand() % 25 + 1;
return (uppercase ? namesUpper[random] : namesLower[random]);
}
int main(void)
{
char buffer[13] = {0};
int loop = 0;
int loopMax = 0;
cout << "Press enter to iniialize..." << endl;
cin.get();
srand(time(0));
do
{
loopMax = rand() % 3 + 4;
buffer[0] = randomChar(true);
for (loop = 1; loop <= loopMax; loop ++)
{
buffer[loop] = randomChar(false);
}
buffer[13] = '\0';
cout << "Random Name:\t" << buffer << endl << endl;
cin.clear();
}
while (cin.get());
return 0;
}