/**************************************************************************** Laboratory Exercise #6 ****************************************************************************/ using namespace std; #include typedef unsigned long int base10; struct Record { unsigned A; char B[20]; float C; }; Record Temp, List[100]; int main() { // The operator "sizeof" evaluates to the number of bytes for its operand, // which can be a data type or a data object. cout << endl; cout << "float: " << sizeof(float) << endl; // ____________ cout << "double: " << sizeof(double) << endl; // ____________ cout << "char: " << sizeof(char) << endl; // ____________ cout << "short int: " << sizeof(short int) << endl; // ____________ cout << "int: " << sizeof(int) << endl; // ____________ cout << "unsigned char: " << sizeof(unsigned char) << endl; // ____________ cout << "unsigned short: " << sizeof(unsigned short) << endl; // ____________ cout << "unsigned int: " << sizeof(unsigned int) << endl; // ____________ cout << "unsigned: " << sizeof(unsigned) << endl; // ____________ cout << endl; cout << "Temp: " << sizeof(Temp) << endl; // ____________ cout << "Temp.A: " << sizeof(Temp.A) << endl; // ____________ cout << "Temp.B: " << sizeof(Temp.B) << endl; // ____________ cout << "Temp.C: " << sizeof(Temp.C) << endl; // ____________ cout << "List: " << sizeof(List) << endl; // ____________ cout << "List[0]: " << sizeof(List[0]) << endl; // ____________ cout << "N: " << sizeof(List) / sizeof(List[0]) << endl; // ____________ cout << endl; // Cast all addresses so that they are displayed as decimal values // (instead of hexadecimal values) using a "typedef". // Assume that "List" begins at address 6296832 (base 10) cout << "&List[0]: " << (base10) &List[0] << endl; // ___6296832__ cout << "&List[0].A: " << (base10) &List[0].A << endl; // ____________ cout << "&List[0].B: " << (base10) &List[0].B << endl; // ____________ cout << "&List[0].C: " << (base10) &List[0].C << endl; // ____________ cout << "&List[0].B[0]: " << (base10) &List[0].B[0] << endl; // ____________ cout << "&List[0].B[4]: " << (base10) &List[0].B[4] << endl; // ____________ cout << endl; cout << "&List[5]: " << (base10) &List[5] << endl; // ____________ cout << "&List[5].A: " << (base10) &List[5].A << endl; // ____________ cout << "&List[5].B: " << (base10) &List[5].B << endl; // ____________ cout << "&List[5].C: " << (base10) &List[5].C << endl; // ____________ cout << "&List[5].B[0]: " << (base10) &List[5].B[0] << endl; // ____________ cout << "&List[5].B[4]: " << (base10) &List[5].B[4] << endl; // ____________ cout << endl; }