freelanceprogrammers.org Forum Index » C
Array Decays2Pointer
Joined: 17 Jul 2003
Posts: 2
Array Decays2Pointer
Hello All,
char a[6] = "abcd";
char *p = "abcd";
->I understood that name of an array is a CONSTANT, which means that
char a[6]; which means that if if were to read a[3], compiler goes to the start of the object named "a" and increments 3 spaces to reach at a[3]
->in case of p[3], compiler goes to the object pointed to by "p", and increments by 3 to reach at p[3].
This is what i learnt from http://www.eskimo.com/~scs/C-faq/q6.2.html
Except for the point that an array name cannot be changed and will always have to point to the start of object a unlike "p" which could be point to any other object which essentially means a[3] DOES`NT necessarily have to be p[3].Is there anything else?
But then why does http://www.eskimo.com/~scs/C-faq/q6.3.html say that, QUOTED:
"The exceptions are when the array is the operand of a sizeof or & operator, or is a string literal initializer for a character array."
array in the case of string literal DOESn`t decay into an array???????
Sorry about the long mail, had to make the point clear where i didn`t understand....
thanks all
Kitta
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
China Wholesale - Electronics Products
Character Studio - Tutorials and Help
China Wholesale - Electronics Products
Character Studio - Tutorials and Help







