Search:
Forum
Beginners
Array question
Array question
Oct 18, 2009 at 2:38pm UTC
JRevor
(147)
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
Oct 18, 2009 at 2:43pm UTC
Bazzy
(6281)
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
Oct 18, 2009 at 2:58pm UTC
huzhanchi
(7)
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};
Oct 18, 2009 at 2:59pm UTC
JRevor
(147)
Thanks. (also, thanks for the second answer huzhanchi, but the idea was not to do that on initialization, but later on)
Last edited on
Oct 18, 2009 at 3:00pm UTC
Topic archived. No new replies allowed.
C++
Information
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs