Thread: Picking out random words

  1. #16
    Registered User
    Join Date
    Sep 2005
    Location
    USA
    Posts
    69
    Thanks alot Ancient Dragon, that works great.
    Adam

  2. #17
    Banned Yuri's Avatar
    Join Date
    Aug 2005
    Location
    Breukelen, The Netherlands
    Posts
    133
    I don't know what you tried, beanroaster but this will works:
    Code:
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
        while ( EOF ){
              
        int Random;          
        char String[] = "";
              
        srand( ( unsigned ) time ( NULL ) );
        Random = rand() % 10;
        
        switch ( Random ){
               
        case 0 : strcat ( String, "word0" );
        break;
        case 1 : strcat ( String, "word1" );
        break;
        case 2 : strcat ( String, "word2" );
        break;
        case 3 : strcat ( String, "word3" );
        break;
        case 4 : strcat ( String, "word4" );
        break;
        case 5 : strcat ( String, "word5" );
        break;
        case 6 : strcat ( String, "word6" );
        break;
        case 7 : strcat ( String, "word7" );
        break;
        case 8 : strcat ( String, "word8" );
        break;
        case 9 : strcat ( String, "word9" );
        break;
        default : strcat ( String, "word10" );
        break;
        }
        
        cout<<"Your word is: "<< String <<endl;
        cin.get();
        system("cls");
        }
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Another brain block... Random Numbers
    By DanFraser in forum C# Programming
    Replies: 2
    Last Post: 01-23-2005, 05:51 PM
  2. New Theme
    By XSquared in forum A Brief History of Cprogramming.com
    Replies: 160
    Last Post: 04-01-2004, 08:00 PM
  3. Replies: 1
    Last Post: 12-14-2002, 01:51 AM
  4. random selection of words from a text file
    By archie in forum C++ Programming
    Replies: 0
    Last Post: 03-02-2002, 12:59 AM