Afficher un message
Vieux 18/10/2007, 22h51   #5
Old Wolf
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: The sizeof operator : sizeof(++i)

On Oct 18, 11:32 pm, vipvipvipvip...@gmail.com wrote:
> On Oct 18, 1:22 pm, Kislay <kislaychan...@gmail.com> wrote:
>
> > On executing the above code , the value of i obtained as 10 . What
> > happens to the increment ? Why does not not that take place ? Has it
> > got something to do with the fact that sizeof is a compile-time
> > operator ?

>
> sizeof is not preprocessed, but evaluated/replaced by the compiler.


As is every operator..

> sizeof does not evaluate what it's given, that's why sizeof *p works
> with uninitialized pointers, for example.


For some arguments to sizeof, it is allowed to evaluate
the argument. for example:

void func(int n, int array[n][n])
{
int i = 0;
printf("size is %zu\n", sizeof array[i++]);
printf("i is %d\n", i); // could be either 0 or 1
}

  Réponse avec citation
 
Page generated in 0,04628 seconds with 9 queries