c - sizeof operator returns 4 for (char + short ) -


this question has answer here:

given code snippet:

    #include <stdio.h>      int main() {          short = 20;         char c = 97;          printf("%d, %d, %d\n", sizeof(i), sizeof(c), sizeof(c + i));          return 0;     } 

why sizeof(c + i) == 4?

c + i integer expression (integer promotion!), sizeof() returns sizeof(int)


Comments