LOGBOOK

HELP

Quiz Entry - updated: 2026.07.07

What is the purpose of the sizeof operator in C?

sizeof gives the size in bytes of a type or object, returned as a size_t (an unsigned type).

sizeof(char)   = 1  (always)
sizeof(int)    = 4  (typically)
sizeof(long)   = 4 or 8  (platform-dependent)
sizeof(void *) = 4 or 8  (pointer size)

Important notes:

  • Returns size_t (unsigned type)
  • For arrays: returns total bytes, not element count
  • For pointers: returns pointer size, not pointed-to data size
int arr[10];
// 40 bytes (10 × 4)
sizeof(arr)
// 4 bytes
sizeof(arr[0])
// 10 elements
sizeof(arr)/sizeof(arr[0])

From Quiz: REVE1 / Number Representations | Updated: Jul 07, 2026