ProgrammingModerate

In C (not C++), what is sizeof('A')?

  1. A. 1 byte, like sizeof(char)
  2. B. 2 bytes, always
  3. C. sizeof(int), which is usually 4 bytes
  4. D. sizeof(char) plus padding

Correct answer: C. sizeof(int), which is usually 4 bytes

A character constant has type int in C, so sizeof('A') equals sizeof(int). In C++ it would be char and give 1.

More C Programming questions

Exams that ask this topic