

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 6
click for more info
Not enough gems
Cost: 6 gems
1: Welcome to Memory Management
incomplete
2: C Program Structure
incomplete
3: Interpreted Quiz
incomplete
4: C Is Compiled
incomplete
5: Comments
incomplete
6: Basic Types
incomplete
7: Strings
incomplete
8: Printing Variables
incomplete
9: Compilation: Types
incomplete
10: Variables
incomplete
11: Constants
incomplete
12: Functions
incomplete
13: Void
incomplete
14: Unit Tests
incomplete
15: Math Operators
incomplete
16: If Statements
incomplete
17: Logical Operators
incomplete
18: Ternary
incomplete
19: Type Sizes
incomplete
20: Sizeof
incomplete
21: For Loop
incomplete
22: While Loop
incomplete
23: Do While Loop
incomplete
24: Pragma Once and Header Guards
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
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_tThe size_t type is a special type that is guaranteed to be able to represent the size of the largest possible object in the target platform's address space (i.e. can fit any single, non-struct value inside of it).
It's also the type that sizeof returns.
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.