sizeof()
Anonymous contributor
Published Feb 8, 2025
Contribute to Docs
In C, the sizeof()
operator returns an integer representing the memory size of a data type or variable in bytes.
Syntax
sizeof(input)
input
: The data type or variable whose memory size is to be calculated.
Example
The following example demonstrates the usage of the sizeof()
operator:
#include <stdio.h>int main() {// Calculate the memory size of the 'int' data typeint res = sizeof(int);// Print the resultprintf("Size of int: %d bytes\n", res);return 0;}
The above code produces the following output:
Size of int: 4 bytes
All contributors
- Anonymous contributor
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.