The sizeof operator returns the size in bytes of its operand. Operand may be a variable or data type.
Here are few examples,
Example 1:
main() { char c; printf("%d,%d\n", sizeof c, sizeof(int)); /* returns 1, 4*/ } |
Example 2:
(main) { struct { int a; int b; }s; printf ("% d \ n", sizeof (s)); /* returns 8*/ } |
Example 3:
main() { short array [] = {1, 2, 3, 4, 5}; short la = sizeof (array) / * returns 10 * / } |