C/Pointers with words

From Attie's Wiki
(Difference between revisions)
Jump to: navigation, search
m (Created page with 'Having been criticized by my colleagues, I decided to add some words to my Pointers page. ==A Variable== If we start by thinking about a standard variable 'i', assuming an x…')

Revision as of 19:51, 12 March 2012

Having been criticized by my colleagues, I decided to add some words to my Pointers page.

A Variable

If we start by thinking about a standard variable 'i', assuming an x86, 32-bit system - 32-bit (4 byte) address and integer sizes.

int i;

This is just a block of 4 bytes that the compiler promises it will find memory for. In reality this comes from the stack, but that is a detail for another time.

If we now assign 0xDEADBEEF to i and represent the memory visually, we might find the following (the colouring will become apparent later).

int i;
 
i = 0xDEADBEEF;
Address Value Note
...
0xBF893E8F 0xDE i MSB
0xBF893E8E 0xAD i
0xBF893E8D 0xBE i
0xBF893E8C 0xEF i LSB
...

This is very simple. Store a value in some memory.

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox