0

I have the following code:

#include <stdio.h>

int main(void)
{
    char c1  = 'A';
    int size1;
    int size2;

    size1 = sizeof(c1);
    size2 = sizeof('A');
    printf("%d %d\n", size1, size2);
    return 0;
}

The output of the above code is 1 4. My question why 'A' in sizeof('A') is promoted to a integer, while c1 in sizeof(c1) is not promoted to a interger?

Charles0429
  • 1,406
  • 5
  • 15
  • 31
  • 2
    I never tire of pointing out: `sizeof` is not a function, and it returns `size_t`, not `int`. – unwind Jun 30 '14 at 08:10
  • 1
    *why 'A' in sizeof('A') is promoted to a integer* -- what makes you think it was promoted? It wasn't; it's always an int. – Jim Balter Jun 30 '14 at 09:44

0 Answers0