Asp tutorial. net sizeof
Introduction
Pascal's memory capacity measurement function:
Determine the data type length in C language
Edit the usage of this section
Var
A: array [1 .. 10000] of longint;
Begin Writeln (SizeOf ());
End.
Output: 40000
If Integer is defined,
Output: 20000
Keyword used to judge the length of a data type in C language
Usage
Sizeof (type specifier, array name or expression );
Or
Sizeof variable name
1. Definition:
Sizeof is an operator in C/C ++. In short, sizeof is used to return the memory bytes occupied by an object or type.
 # 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;
}
 Instance 2
 # Include <iostream. h>
 Union u_tag {
Int I;
Double d;
} U = {88 };
Struct s_tag {
Int I;
Double d;
} S = {66, 1.234 };
 Int main ()
{
Int size;
Size = sizeof (union u_tag );
Cout <"sizeof (union u_tag) =" <size <endl;
U. I = 100;
Cout <"u. I =" <u. I <endl;
U. d = 1.2345;
Cout <"u. d =" <u. d <endl;
Size = sizeof (u. d );
Cout <"sizeof (u. d) =" <size <endl;
Cout <"s. I =" <s. I <endl;
Cout <"s. d =" <s. d <endl;
Size = sizeof (struct s_tag );
Cout <"sizeof (struct s_tag) =" <size <endl;
}
 Sizeof class
 # Include <iostream>
 Class EmptyClass {
};
 Int main ()
{
Std: cout <"sizeof (EmptyClass):" <sizeof (EmptyClass)
<'N ';
}