home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C Programming Starter Kit 2.0
/
SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso
/
tybc4
/
sizeof1.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1993-03-18
|
1KB
|
41 lines
/*
simple program that returns the data sizes using the sizeof()
operator with variables and data types.
*/
#include <iostream.h>
main()
{
short int aShort;
int anInt;
long aLong;
char aChar;
float aReal;
cout << "Table 1. Data sizes using sizeof(variable)\n\n";
cout << " Data type Memory used\n";
cout << " (bytes)\n";
cout << "------------------ -----------";
cout << "\n short int " << sizeof(aShort);
cout << "\n integer " << sizeof(anInt);
cout << "\n long integer " << sizeof(aLong);
cout << "\n character " << sizeof(aChar);
cout << "\n float " << sizeof(aReal);
cout << "\n\n\n\n";
cout << "Table 2. Data sizes using sizeof(dataType)\n\n";
cout << " Data type Memory used\n";
cout << " (bytes)\n";
cout << "------------------ -----------";
cout << "\n short int " << sizeof(short int);
cout << "\n integer " << sizeof(int);
cout << "\n long integer " << sizeof(long);
cout << "\n character " << sizeof(char);
cout << "\n float " << sizeof(float);
cout << "\n\n\n\n";
return 0;
}