Pointers

Pointer variables can hold an address. Declaration examples below

int* p0;
int *p1;
int * p2; 
int* p3, p4;

Address of var stored in p0

int* p0 = &var;

Swap function using pointers

void swap(int* i, int* j) {
    int t = *i;
    *i = *j;
    *j = t;
}

Last updated