L
L
little_schoolboy2014-03-30 13:16:00
C++ / C#
little_schoolboy, 2014-03-30 13:16:00

How to fill a long array with variables in SI?

Hello, the task is to fill an array with existing variables like this

mass[0] = x1;
mass[1] = z3;
mass[2] = x21;
...
mass[59]=x85;

writing manually mass[1] mass[2] mass[3] is very laborious, and you can do it like this
mass[i] = x1; i++;
mass[i] = z3;i++;
mass[i] = x21;i++;
...
mass[i]=x85;i++;

but I don't like this way either.
Besides this solution, are there other ways?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alexanius, 2014-03-30
@alexanius

If there is no function by which the values ​​are filled, then you can do something like this:

int a = 1, b = 2, c = 3;
int x[3] = {a, b, c};

And yes, please put "C" in the tags

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question