Thread: How to generate random color names in c ?

  1. #1
    Registered User
    Join Date
    Sep 2013
    Posts
    7

    How to generate random color names in c ?

    I want to print different color names for "nb " times . I get the number " nb " from the user or from text file . if " nb = 3 " then I want to print any 3 different color names which means that I may print ( red , green , blue ) for example . and if " nb=5 " then I have to print any five different color names ( pink , blue , black , red ,white ) fore example .
    note : " nb " may be a large number ( 17 for example )
    how can I do this ?
    Last edited by Islam Assi; 09-07-2013 at 10:48 AM.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    List of colors: A–F - Wikipedia, the free encyclopedia
    Create a file containing names, say 1 per line
    Read file into an array
    Pick a random index to get a random colour name

    Rinse and repeat as necessary.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Sep 2013
    Posts
    7
    thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 07-24-2012, 09:30 AM
  2. Is it possible to generate random text?
    By FingerPrint in forum C++ Programming
    Replies: 6
    Last Post: 07-19-2006, 03:10 PM
  3. generate a random password
    By mabufo in forum C++ Programming
    Replies: 17
    Last Post: 02-23-2006, 05:57 PM
  4. generate random letters
    By Unregistered in forum C++ Programming
    Replies: 2
    Last Post: 05-19-2002, 02:22 AM
  5. Best way to generate a random double?
    By The V. in forum C Programming
    Replies: 3
    Last Post: 10-16-2001, 04:11 PM