Table of Contents

Corning Community College

CSCS2320 Data Structures

Course Wiki Page

Projects

dsi0 ael0

URLs

Binky Pointer Video:

Binky Pointer Video

Basic linked list tutorial

Notes

Pointers:

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
     

Access an address with &

Make y = deadbeef without using “deadbeef” by using the address (&) my man.

 y = &x

Now, y's data is the address of x.

x contains the data '0'

If we do this:

  |0|
  ---
  x
  0xdeadbeef  <- address
     |0xdeadbeef|
     ------------
     y
     0xcoffee <- address
     
 x = 7;
 *y = 13;

Then:

  |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. Ill, dog.

Double pointers are arrays or whatever

  |          |
  ------------
  z
  
  signed char **z = NULL;
  

So we're gonna give this some garbage

  |0xcoffee|
  ----------
  z
  0xc05fefe

And do nothing with it because we kind of just stopped I think.

Memory addresses are 8 bytes on 64 bit linux systems. 4 bytes on 32 bit linux systems.

Other