Sizeof operator again

char *p="Hello World";
int a;
char b;
printf("%d\n",sizeof(p++));
printf("%c\n",*p);

printf("%d",sizeof(a,b));
printf("%d",sizeof(b,a));
 
Explain why p didn't get incremented and 
what is the use of comma operator here.

Comments

  1. Hello Sir,
    When operand of the sizeof operator s is an expression then the expression is not evaluated.
    Comma operator is used to separate the expressions where the value of the left expression is discarded and value of right most expression is taken.

    ReplyDelete
  2. @vivek sizeof is a compile time operator,while evaluating it fetches only declaration and real operand is never fetched so expression is never evaluated...:)

    ReplyDelete
  3. ok sir..got it.. :)

    ReplyDelete
  4. sizeof() is a compile - time operator.
    And ++ can't be operated at compile-time.

    ReplyDelete

Post a Comment

Popular posts from this blog