Help With Random Number Generator

This is a discussion on Help With Random Number Generator within the C Programming forums, part of the General Programming Boards category; If I had 6 Words and I want the user to randomly receive one of the 6 words every time ...

  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,175
    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, 11: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, 07: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, 12:57 PM
  5. random number generator
    By noodle24 in forum C++ Programming
    Replies: 7
    Last Post: 05-11-2006, 11:41 AM

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