PDA

Click to See Complete Forum and Search --> : Random word generator


|2eM!x
Sep 20th, 2005, 08:40 PM
I know im not good...just trying to help :wave:

#include <iostream>
#include <string>
#include <ctime>

using namespace std;

void RndWord(long iLen){
char ch;
string mystr;
char i=0;
while (i < iLen){
ch = (rand()%(('Z'-'A'))+'A');
mystr += ch;
i++;
}
cout << mystr << "\n";
}

int main(void){
long lenword;
srand(time(NULL));
cout << "Word length?\n";
cin >> lenword;
RndWord(lenword);
return 0;
}

kfcSmitty
Jan 29th, 2008, 02:39 PM
Just a note:

you may want to add


system("Pause");


After


RdnWord(lenword);


so you can actually see the output of the word.

boyyo11
Oct 31st, 2010, 04:35 AM
Or put under
RndWord(lenword);
put
cin.get();
cin.get();