Saturday 16 April 2016

Example program for pointers: how to declare and initialize the pointer

//Example program for pointers: how to declare and initialize the pointer
#include < stdio.h >

    int main(void) {

        int a;
        int * pa;

        a = 14;
        pa = & a;

        printf("\nValue of variable a: %d\n", a);
        printf("Address of variable a: %p\n", & a);
        printf("Value of pointer pa: %p\n", pa);
        printf("Dereferenced value of pointer pa: %d\n\n", * pa);

        return 0;

    } //end main

Pointers