In a question I posted here: C++ – class issue
One of the replies, which was from @SanSS mentioned the following part of the reply:
Arrays in C are used through pointers…
How is this done? And, can you clarify this by an example if possible?
Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
What is meant by that could be a couple of things:
1) the subscript operator is defined in terms of pointer arithmetic. C99 6.5.2.1/2 “Array subscripting” says:
As an example, assume you have an array declated like so:
char s[] = "012345";All of the following evaluate to ‘4’:
s[4]*(s + 4)4[s]– thisunusual construct might surprise you,
but because of the way that
subscripting is defined by the
standard, this is equivalent to
*(4 +, which is the same ass)
*(s + 4)and the same as
s[4].2) (closely related to the above) array names evaluate to pointers to the first element of the array in most expressions (being the operand to the
sizeofoperation being the main exception).