Link to home
Start Free TrialLog in
Avatar of Mannsi
Mannsi

asked on

Need to use a running variable name in c++

Hello experts,

Maybe this is a trivial question but I haven't figured it out. I need to reference variable names based on a loop counter. A stupid example would be the "code" below.

I could do this with the Me() function in VB. How do I do this in c++ ?
int array1[10];
int array2[10];
 
for (i=1;i != 3;i++)
{
       array'i'[i] = i
}
       //Here I would like to put the number 1 in array1[1] and 2 in array2[2]

Open in new window

Avatar of Mushq
Mushq
Flag of Pakistan image

please check the following code.
for (i=1; i <= 3; i++)
{
       array1[i] = i;
       array2[i] = i;
}
ASKER CERTIFIED SOLUTION
Avatar of sunnycoder
sunnycoder
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial