`sizeof` — C Keyword
`sizeof` — C Keyword
The sizeof keyword in C: yields the size in bytes of a type or object.
`sizeof` — C Keyword
The sizeof keyword in C: yields the size in bytes of a type or object.
Use reference pages to confirm names, categories, nearby facilities, and the constraints that matter before writing or reviewing code.
sizeof (C)A compile-time operator that yields the size in bytes (as size_t) of a type or expression. The expression is not evaluated.
sizeof(type)
sizeof expression
#include <stdio.h>
struct Point { float x, y; };
int main(void) {
printf("sizeof(char) = %zu\n", sizeof(char)); /* 1 */
printf("sizeof(int) = %zu\n", sizeof(int)); /* usually 4 */
printf("sizeof(double) = %zu\n", sizeof(double)); /* usually 8 */
printf("sizeof(Point) = %zu\n", sizeof(struct Point)); /* usually 8 */
int arr[10];
printf("element count = %zu\n", sizeof arr / sizeof arr[0]); /* 10 */
/* Expression is unevaluated */
int x = 5;
printf("sizeof(x++) = %zu\n", sizeof(x++)); /* x is NOT incremented */
printf("x = %d\n", x); /* 5 */
return 0;
}
sizeof(char) is always 1 by definition.%zu format specifier for size_t values in printf.sizeof is evaluated at runtime.sizeofint main() {
// Pick one facility from this reference page.
// Write the smallest program that exercises its main precondition,
// complexity rule, or lifetime constraint before scaling up.
return 0;
}