Like Tree1Likes
  • 1 Post By Salem

How to generate random color names in c ?

This is a discussion on How to generate random color names in c ? within the C Programming forums, part of the General Programming Boards category; I want to print different color names for "nb " times . I get the number " nb " from ...

  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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,532
    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.
    Islam Assi likes this.
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  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, 04: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

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