// Determine sizes of types for a particular environment // (C) 2002 Bill Lenhart #include // #include inserts the contents of a header file // iostream provides basic I/O services, including input and output streams // cout is the "default" output stream; endl is the end-of-line value int main(void) { cout << "Built-in types and their sizes." << endl; cout << "All values are multiples of the size of a char." << endl; cout << "So, e.g., a char has size 1 (presumably 1 byte)" << endl; cout << endl; cout << "Plain types" << endl; cout << "bool: " << sizeof(bool) << endl; cout << "char: " << sizeof(char) << endl; cout << "short: " << sizeof(short) << endl; cout << "int: " << sizeof(int) << endl; cout << "long: " << sizeof(long) << endl; cout << "float: " << sizeof(float) << endl; cout << "double: " << sizeof(double) << endl; cout << endl; cout << "void* is a generic pointer type...." << endl; cout << "void*: " << sizeof(void*) << endl; cout << endl; cout << "Unsigned types" << endl; cout << "unsigned char: " << sizeof(unsigned char) << endl; cout << "unsigned short: " << sizeof(unsigned short) << endl; cout << "unsigned int: " << sizeof(unsigned int) << endl; cout << "unsigned long: " << sizeof(unsigned long) << endl; cout << endl; cout << "There are also 'signed' types, but we don't care about them here." << endl; // Notice that the previous command spanned multiple lines in the file. // This (along with good indenting) helps maintain readability. // By popular demand return 0; }