/*** Prints Data on C/C++ data types ***/ /*** Also an example of a simple macro***/ /* * PROBLEM * How are integers etc stored on my computer? * * ANALYSIS * Use the ready made "sizeof" function and libraries to * print out sizezs, limits, etc... * * DESIGN * * Print * Information * | * ---------------- * | | | * Print Print Print * Sizes Limits Floats * */ #define BAR cout <<"\n----------------------------" // The above is a "macro" (page 331). Just so you've seen one. #include #include #include int main() { void print_sizes(); void print_limits(); void print_floats(); print_sizes(); print_limits(); print_floats(); cout <<"\n\n"; return 0; } void print_sizes()// Taken from Kernigan and Ritchie many years ago { cout <<"\nData Type "<< "Size in Bytes"; BAR; cout <<"\n char "<< sizeof(char); cout <<"\n short "<< sizeof(short); cout <<"\n int "<< sizeof(int); cout <<"\n long "<< sizeof(long); cout <<"\nunsigned "<< sizeof(unsigned); cout <<"\n float "<< sizeof(float); cout <<"\n double "<< sizeof(double); cout <<"\nl double "<< sizeof(long double); BAR; } void print_limits()// Based on Table 7.1, page 335, Friedman & Koffman { cout <<"\nInfo in "; cout<<"\nCHAR_BIT = "<"; cout<<"\nSTUB = "<<"Stub"; BAR; return;//to main program }