sizeof Operator
sizeof gives the size in bytes of a type or variable. Use %zu to print it.
Example
#include <stdio.h>
int main(void) {
printf("%zu %zu %zu %zu\n", sizeof(char), sizeof(int), sizeof(double), sizeof(long long));
int a[10];
printf("%zu items\n", sizeof a / sizeof a[0]);
return 0;
}Result
1 4 8 8 10 items
Exercise
Size in bytes.
(int)Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.