C++ examples for Operator:sizeof
sizeof operator gets the number of bytes occupied by a type, or by a variable.
Here are some examples of its use:
#include <iostream> int main()/*from w w w. j a v a 2s.c om*/ { int height {74}; std::cout << "The height variable occupies " << sizeof height << " bytes." << std::endl; std::cout << "Type \"long long\" occupies " << sizeof (long long) << " bytes." << std::endl; std::cout << "The expression height*height/2 occupies " << sizeof (height*height/2) << " bytes." << std::endl; }