cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
user name:
password:
Forgot your password?
please wait
try again
cancel
forgot your password?
sign up
log in
[Legacy version]
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
Array question
Array question
Oct 18, 2009 at 2:38pm
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
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
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
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
Oct 18, 2009 at 3:00pm UTC
Topic archived. No new replies allowed.