CS 24000 Lecture Notes - Lecture 10: Endianness, Address Space, C Dynamic Memory Allocation

24 views7 pages

Document Summary

Printing pointers: * is value at operator, & is address of operator, to print pointers we often use the 0x%lx instead of %;f format since %ld may print pointers as negative numbers. If you want to print pointers as unsigned decimals, us %lud or just %lu (will print positive number . Little endian/big endian: assume the following statements: int i = 5; unsigned char * p; p = (unsigned char*) &i, 5 may be stored in two ways: Code to determine if machine is little endian. Int islittleendian() { int i = 5; unsigned char * p = (unsigned char *) &i; if (p[0] == 5) { return 1; else { return 0; Little endian/big endian: litter endian: put 5 at 100 (intel, arm, vax, lowest significant byte is placed in the lowest address, big endian: put 5 at 103 (sparc, motorola, lowest significant byte in the highest address.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents