Thread: element selection

  1. #1
    Registered User
    Join Date
    Oct 2003
    Posts
    10

    element selection

    Does anybody know if I can create a list of elements and randomally select an element from that list.
    I need the program display more than one data type, and I know I could use several arrays, one for each type.but I want to know if there is another way of doing it, I also know that i could use multiple case or if statements.

    But I think I remember seeing in someones source code a list of items seperated of braces without any keywords in between.

    Just in case I'm not clear this is what I'm looking for, something like it anyway. Maybe it doesn't exist.

    Code:
    {
        black;
        green;
        654;
    }
    {
       red;
       blue;
       8784;
    }
    Thanks boys
    Last edited by Stinky; 11-10-2003 at 03:41 PM.

  2. #2
    Registered User sean345's Avatar
    Join Date
    Mar 2002
    Posts
    346
    You could use a structure and then just make an array of that struct.
    Code:
    typedef struct Test{
         int Num;
         char Letter;
         char String[32];
    } TEST;
    
    //Later on
    TEST Example[10] //Creates an array of Test structs
    - Sean
    If cities were built like software is built, the first woodpecker to come along would level civilization.
    Black Frog Studios

  3. #3
    Registered User
    Join Date
    Oct 2003
    Posts
    10
    Your right. I actually forgot about structures, but its not what I'm looking for.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 01-05-2008, 11:30 PM
  2. selection problem
    By Ken JS in forum C Programming
    Replies: 3
    Last Post: 08-04-2007, 09:47 PM
  3. Sorting a 2-dimensional array
    By kmoyle73 in forum C++ Programming
    Replies: 3
    Last Post: 05-05-2004, 01:54 PM
  4. Struct *** initialization
    By Saravanan in forum C Programming
    Replies: 20
    Last Post: 10-09-2003, 12:04 PM
  5. sorting
    By penny_731729 in forum C Programming
    Replies: 3
    Last Post: 04-28-2003, 10:56 AM