robertwessel2@yahoo.com
6/17/2016 4:29:00 AM
On Thu, 16 Jun 2016 19:26:20 -0700 (PDT), maykov@gmail.com wrote:
>On Friday, December 12, 1997 at 12:00:00 AM UTC-8, Alexey Maykov wrote:
>> Hi !
>>
>> One man told me that the following construction is legal for c:
>> int [10] a;
>> because square brackets is the kind of the komment symbol in the ansi c
>> standard, but VC++5.0 gives a compile error.
>> So, the question is, does the man wrong, or i did something wrong ?
>
>Here is what that man said:
>
>a[5] is the same as 5[a]
It's not true for declarations, so "int 10[a]" doesn't work. OTOH,
when you access an array, you can write:
a[10] = 3;
-or-
10[a] = 3;
and accomplish the same thing. That's because the array accessor
essentially decays into a pointer expression. IOW, the two above
lines are equivalent to:
*(a+10) = 3;
-and-
*(10+a) = 3;
The later form ("10[a]") is primarily used to confuse newbies.
But it's in no way a comment.