Array question

Why does this not work? How can i do that without doing p[0] = 1; p[1]= 0;?
1
2
   int p[2];
   p = {1,0};

Thanks in advance
Why does this not work?
{ } work only for initialization
How can i do that without doing p[0] = 1; p[1]= 0;?
You can't
hi JRevor

1
2
int p[2];
p = {1,0};

"p"is a const pointer that point to the first adress of array "p[2]",and cannot be assigned as left operand

you can do it like this
int p[2]={1,0};
Thanks. (also, thanks for the second answer huzhanchi, but the idea was not to do that on initialization, but later on)
Last edited on
Topic archived. No new replies allowed.