How to form a variable using another variable's name?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • selvialagar
    New Member
    • Apr 2008
    • 57

    How to form a variable using another variable's name?

    Let me tell my problem.There are list of parameters in a list box. User can select any number of Parameters (Maximum Limit is 10). Now I want to create dynamic arrays for all the parameters. Suppose the user selects 3 parameters,
    the name of the dynamic arrays would be like this,

    Byte Parameter_1[]
    Byte Parameter_2[]
    Byte Parameter_3[]

    for(int i=1;i<=3;i++)
    {
    Byte Parameter_+i+[];
    }
    I tried this.But it doesn't work...


    How to create these arrays dynamically in a single statement.
    Here 1,2,3 are looping variables.
    Plz give be suggestions.... ..
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    Try a 2 dimensional array

    Code:
    #define MAX_PARAMETERS               10
    #define MAX_PARAMETER_LENGTH   50
    
    Byte Parameter[MAX_PARAMETERS][MAX_PARAMETER_LENGTH];

    Comment

    • weaknessforcats
      Recognized Expert Expert
      • Mar 2007
      • 9214

      #3
      Read this article from the C/C++ Insights: http://bytes.com/topic/c/insights/77...rrays-revealed.

      Comment

      Working...