#include <stdio.h>

/* Terry Harvey CISC105 Section 21 TA Aaron*/

/* This program has the same result as

int x;
x = 4;
printf("%d", x);

only it uses pointers to do it. This is only appropriate for teaching
purposes, but it demonstrates the syntax for using pointers.
*/

int main(){

    int *p;
    p = (int*) malloc( sizeof(int) ); //why does malloc need to have a
                                      //unary type cast?
    *p = 4;
    printf("%d\n", *p);

    /* In general, always check to see if memory was properly allocated
      AND free the memory when you are done using it. The memory is
      freed when the program ends, but your program may become a
      function in another program, so use good style and free().*/

    free( p );

    return 0;
}
