[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Tinycc-devel] Strange sizeof construct
From: |
Simon 'corecode' Schubert |
Subject: |
Re: [Tinycc-devel] Strange sizeof construct |
Date: |
Tue, 13 Nov 2007 20:15:03 +0100 |
User-agent: |
Thunderbird 2.0.0.6 (X11/20071022) |
Marc Andre Tanner wrote:
> Could a C guru out there please tell me why the following works? Extra points
> if you can explain why it makes sense.
>
> #include <stdio.h>
>
> int main(){
> int arr[10];
> printf("%d\n",sizeof arr[0]); // ok
> printf("%d\n",sizeof(arr[0])); // ok
> printf("%d\n",sizeof(arr)[0]); // ok, but why?
> return 0;
> }
I think it is some kind of precedence rule. sizeof after all is an
operator and not a function. Seems that [] is binding stronger than sizeof.
cheers
simon