I'm trying to figure out how to generate random words. They don't need to make sense. For instance: it can generate "dfgag" "sge" sdvbsvdv". It would be perferable to make it generate less than 7 chars.
I've tried looking online but I can't find anyone who has done this.
Does anyone have a function, a place online, or even pseudo code that can point me in the right direction?
Random Word Generator
Page 1 of 12 Replies - 20676 Views - Last Post: 26 October 2006 - 07:44 PM
Replies To: Random Word Generator
#2
Re: Random Word Generator
Posted 26 October 2006 - 07:28 PM
One suggestion would be to generate a random number between 2 and 7 (the length of the word), then, for that number of letters, generate a random number between 1 and 26. Take that letter of the alphabet and repeat.
#6
Re: Random Word Generator
Posted 26 October 2006 - 07:44 PM
Someone helped me with this:
it works pretty good. it generates 499999 "full names" in under a minute
void rword (char *word)
{
int len = rand () % 6 + 1;
word [len] = 0;
while (len) word [--len] = 'a' + rand () % 26;
}
int main ()
{
char word[7];
char word2[7];
int x=0;
srand(time(0));
while (x<500000)
{
rword(word);
rword(word2);
cout << word << ' ' << word2 << endl;
//printf ("%s\n", word);
x++;
}
}
it works pretty good. it generates 499999 "full names" in under a minute
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote



|