notes:data
This is an old revision of the document!
Corning Community College
CSCS2320 Data Structures
Course Wiki Page
Projects
dsi0 ael0
URLs
Binky Pointer Video: https://www.youtube.com/watch?v=f-pJlnpkLp0
Notes
char x = 0;
char → 1 byte (8 bits) Default char → signed (2^8 → 256 → -128, +127 [one is used for positive/negative value])
the asterisk (*) indicates a “pointer”
signed char *y = NULL; ^
(void*)0 Void pointers are raw memory
|0| --- x 0xdeadbeef |NULL(0)| --------- y 0xcoffee
Make y = deadbeef without using “deadbeef” by using the address (&)
y = &x
Now, y's data is the address of x x contains the data '0'
|0| --- x 0xdeadbeef <- address |0xdeadbeef| ------------ y 0xcoffee <- address x = 7; *y = 13;
Now:
|13| ---- x 0xdeadbeef <- address |0xdeadbeef| ------------ y 0xcoffee <- address
x is now 13 because y is x's address, and you 'pointed' 13 to the address
Other
notes/data.1535031817.txt.gz · Last modified: 2018/08/23 09:43 by cmerola2