Picking out random words

This is a discussion on Picking out random words within the C++ Programming forums, part of the General Programming Boards category; Thanks alot Ancient Dragon, that works great....

  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");
        }
    }

Page 2 of 2 FirstFirst 12
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, 04:51 PM
  2. New Theme
    By XSquared in forum A Brief History of Cprogramming.com
    Replies: 160
    Last Post: 04-01-2004, 07:00 PM
  3. Replies: 1
    Last Post: 12-14-2002, 12:51 AM
  4. random selection of words from a text file
    By archie in forum C++ Programming
    Replies: 0
    Last Post: 03-01-2002, 11:59 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21