[ Pobierz całość w formacie PDF ]
.// Fig// Fig.5.17: fig05_17.cpp// Demonstrating the sizeof operator#include <iostream.h>#include <iomanip.h>int main(){char c;short s;int i;long l;float f;double d;long double ld;int array[ 20 ], *ptr = array;cout << "sizeof c = " << sizeof c<< "\tsizeof(char) = " << sizeof( char )<< "\nsizeof s = " << sizeof s<< "\tsizeof(short) = " << sizeof( short )<< "\nsizeof i = " << sizeof i<< "\tsizeof(int) = " << sizeof( int )<< "\nsizeof l = " << sizeof l<< "\tsizeof(long) = " << sizeof( long )<< "\nsizeof f = " << sizeof f<< "\tsizeof(float) = " << sizeof( float )<< "\nsizeof d = " << sizeof d<< "\tsizeof(double) = " << sizeof( double )<< "\nsizeof ld = " << sizeof ld<< "\tsizeof(long double) = " << sizeof( long double )<< "\nsizeof array = " << sizeof array<< "\nsizeof ptr = " << sizeof ptr<< endl;return 0;}sizeof c = 1 sizeof(char) = 1sizeof s = 2 sizeof(short) = 2sizeof i = 4 sizeof(int) = 4sizeof l = 4 sizeof(long) = 4sizeof f = 4 sizeof(float) = 4sizeof d = 8 sizeof(double) = 8sizeof ld = 8 sizeof(long double) = 8sizeof array = 80sizeof ptr = 4
[ Pobierz całość w formacie PDF ]