Start here · Essential guide
The sizeof Operator in C++
Learn how the sizeof operator in C++ works: what it returns in bytes, how it handles arrays, pointers and structs, and common mistakes to avoid.
Syntax and Functions
How the sizeof operator measures types in bytes and how big an int really is.
Start here · Essential guide
Learn how the sizeof operator in C++ works: what it returns in bytes, how it handles arrays, pointers and structs, and common mistakes to avoid.
The size of int in C depends on the platform. The standard sets a 16-bit minimum, and most current systems use 4 bytes. Here's how to check yours.
No, sizeof() is an operator built into C, not a function. Learn why it looks like a function, how it differs from one, and when parentheses are needed.
Yes, sizeof() returns sizes in bytes in C and C++. Learn what a byte means here, how sizeof works with arrays, and why it counts bytes, not elements.
In C, %d prints an int and %s prints a string. Here is what these format specifiers mean, how printf uses them, and how to avoid type mismatches.
Related topics