Results 1 to 3 of 3

Thread: Random word generator

  1. #1

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Random word generator

    I know im not good...just trying to help
    Code:
    #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;
    }

  2. #2
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: Random word generator

    Just a note:

    you may want to add

    Code:
    system("Pause");
    After

    Code:
    RdnWord(lenword);
    so you can actually see the output of the word.

  3. #3
    New Member
    Join Date
    Jun 2010
    Posts
    9

    Re: Random word generator

    Or put under
    Code:
    RndWord(lenword);
    put
    Code:
    cin.get();
    cin.get();

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width