1

I've just taken a programming 101 and straight off the bat I'm stumped.

In the following program I can't understand why 'A', is being stored as 4 bytes when, while stored as a variable char c = 'A', it is only using 1 byte?

#include <stdio.h>
int main()
{
char c = 'A';

//Returns sizeof('A') = 4
printf("sizeof('A') = %u\n", sizeof('A'));

//Returns sizeof(c) = 1
printf("sizeof(c) = %u\n", sizeof(c));

return 0;
}

Any help/insight would be much appreciated!

Rustang
  • 546
  • 5
  • 15

0 Answers0