Thread: Help With Random Number Generator

  1. #1
    Registered User
    Join Date
    Oct 2011
    Posts
    21

    Help With Random Number Generator

    If I had 6 Words and I want the user to randomly receive one of the 6 words every time they entered 1 how would I write that?

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    First you seed the random number generator with something like the current time. You do this with the srand() function.

    Then, every time the user enters 1, you use rand() to pick a random index into your array of 6 words.
    If you understand what you're doing, you're not learning anything.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. using random number generator
    By camel-man in forum C Programming
    Replies: 8
    Last Post: 06-15-2011, 10:19 PM
  2. need a random number generator thats not compleatly random
    By thedodgeruk in forum C++ Programming
    Replies: 1
    Last Post: 06-05-2011, 06:48 AM
  3. random number generator
    By begginer in forum C Programming
    Replies: 1
    Last Post: 02-23-2011, 08:52 AM
  4. need random number generator
    By dnj23 in forum C Programming
    Replies: 12
    Last Post: 07-29-2010, 11:57 AM
  5. random number generator
    By noodle24 in forum C++ Programming
    Replies: 7
    Last Post: 05-11-2006, 10:41 AM