HIDE NAV

Pointer Basics

Shows the basics of pointers (which store to variable memory addresses) in C.

pointerBasics.c


#include <stdio.h>
#include <stdlib.h>

int main(void) {

	//conventional variable a and it's address, &a
	int a = 183;
	printf("a = %d\n", a);
	printf("&a = %d\n", &a);

	//pointer b, and it's contents/value *b
    int *b;
    b = &a;
	printf("b = %d\n", b);
	printf("*b = %d\n", *b);

	// changing the value
	printf("assigning a = -17....\n");
	a = -17;
	printf("a = %d\n", a);
	printf("*b = %d\n", *b);


	return 0;
}