The “sizeof operator” yields the number of bytes contained in its operand, which can be either a general data type or a specific variable. If you apply sizeof to a type name in parentheses, as in the expression
sizeof( int )
the operator yields the size of that data type in bytes. This example yields the value 2, indicating that an int contains two bytes on DOS machines. You can use this feature to determine the sizes of types that are implementation dependent when transporting a program from one machine to another.
If you place sizeof in front of a variable name, the operator returns the number of bytes in the variable. For instance, if you create the string
char my_string[] = "Hello";
the expression
sizeof my_string
yields the value 6, showing that the string contains 5 printing characters and a null character.