What is the difference between the following initialization of a pointer?
char array_thing[10];
char *char_pointer;
what is the difference of the following initialization?
1.) char_pointer = array_thing;
2.) char_pointer = &array_thing
Is the second initialization even valid?
The second initialization is not valid. You need to use:
char_pointer = array_thing;
or
char_pointer = &array_thing[0];
&array_thing
is a pointer to an array (in this case, type char (*)[10]
, and you're looking for a pointer to the first element of the array.
See comp.lang.c FAQ, Question 6.12: http://c-faq.com/aryptr/aryvsadr.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With