0 day streak
c / beginner
Snippet

Measuring Memory with sizeof

The sizeof operator returns the size of a variable or data type in bytes, which is essential for memory management.

snippet.c
c
1
2
double price = 19.99;
size_t size = sizeof(price);
Breakdown
1
sizeof(price)
Calculates the number of bytes occupied by the variable 'price'.
2
size_t
An unsigned integer type used to represent the size of objects.