Thread: indefinite number of datapoints question

  1. #1
    Registered User
    Join Date
    Aug 2003

    indefinite number of datapoints question

    struct intArray(int size)
        switch (size)
            case 1: { int a0; break; }
            case 2: { int a0, a1; break;}
            case 3: { int a0, a1, a2; break; }
    Is there a way to keep specifying member variables in this fashion without specifying a definite number of possible variables?

    For example, when size is 250 I want 250 variables (a0 - a249).

    I realize this looks like a simple array of integers, but for my purposes an array won't work.
    Check out all my dimensions:
    Height, width, and for a limited time only... Depth!

  2. #2
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    look up vector. It's an STL template class that stores a variable number of any type.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. memory issue
    By t014y in forum C Programming
    Replies: 2
    Last Post: 02-21-2009, 12:37 AM
  2. Issue w/ Guess My Number Program
    By mkylman in forum C++ Programming
    Replies: 5
    Last Post: 08-23-2007, 01:31 AM
  3. help with number menu
    By j4k50n in forum C Programming
    Replies: 12
    Last Post: 04-17-2007, 01:33 AM
  4. Question about limiting the number of user inputs in C
    By chobibo in forum C Programming
    Replies: 15
    Last Post: 08-30-2006, 12:37 AM
  5. Question about the wierd number representations
    By Jaken Veina in forum C Programming
    Replies: 13
    Last Post: 04-07-2005, 11:19 PM