Demonstrate sizeof. : sizeof « Operators statements « C++ Tutorial






#include <iostream> 
using namespace std; 
 
int main() 
{ 
  char ch; 
  int i; 
 
  cout << sizeof ch << ' '; // size of char 
  cout << sizeof i << ' ';  // size of int 
  cout << sizeof (float) << ' '; // size of float 
  cout << sizeof (double) << ' '; // size of double 
 
  return 0; 
}
1 4 4 8








3.6.sizeof
3.6.1.Demonstrate sizeof.
3.6.2.sizeof a union
3.6.3.sizeof a class
3.6.4.Object sizes
3.6.5.Using the sizeof operator for base class and derived class
3.6.6.Use sizeof operator on an array name: returns the number of bytes in the array