im having problems in arrays

lets say u have

int x[12]

how to make all the 13 x equal to one value



example
x[0] = 2
x[1] = 2
x[2] = 2
x[3] = 2



how to do that in one line
> int x[12]
> how to make all the 13 x
no, they are only 12 elements. It goes from x[0] to x[11]


to set them all, use a loop or std::fill http://www.cplusplus.com/reference/algorithm/fill/
do
int x[13]={1};
do
int x[13]={1};

Ah, no. That will only initialize x[0] with 1, all other elements will be default initialized to 0.
Topic archived. No new replies allowed.