Pointers

*&x will cancel it out to x.

Double pointers

int a;
int *p;
int **q;

q -> p -> a
  • 30 most common words in the languages.

Pointer arithmetic on 2d array

// you can do addition to get things by row
table = [1|2|3|4]
table+1 = [5|6|7|8] OR *(table + 1)
table+2 = [9|10|11|12] *(table + 2)


for(i = 0; i < 3; i ++)
{
  for(j =0; j <4; j++) {
    printf("%d", *(*(table + i) + j));
  }
  printf("\n");
}

Memory allocation

  • malloc
  • calloc
  • free
  • realloc
int * aP[5] // Array a pointers

int (*pa) [5] // Pointer to array
Written on November 1, 2017