We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Sizeof

C gives us a way to check the size of a type or a variable: sizeof.

You can use sizeof like a function (although, technically it's a unary operator, but that distinction is generally only useful for winning super important internet arguments).

We'll use the sizeof operator in the next few lessons to give us insight into the memory layout of different types in C. This will be particularly useful as we move deeper into C, and essential for understanding pointers.

Pointers are not too bad once you understand the basics! I promise!

size_t

size_t is an unsigned integer type that can represent the size in bytes of any object.

It's also the type that sizeof returns.

Assignment

Take a look at the results before moving on! Notice that a char and bool only take up 1 byte (8 bits), while the other types take up more space.