//-----------------------------------------------------------------------------
// memoryTricks.c
//
// program will demonstrate the dynamic use of memory
// it shows what can happen if you do not take care
// of what you are doing
//
// group: group 1,13 study assistant AltiHar
//
// author: Altinger Harald 0630xxx
//
// last change: created all (Altinger Harald)
//-----------------------------------------------------------------------------
//

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

//----------------------------------------------------------------------------- 
/// 
/// The main program. 
///
/// run the program
/// 
///  @return int  always zero 
// 
int main()
{
  int *memory = NULL;
  
  memory = malloc(sizeof(int)); //append the momory
  printf("uninitialized memory: %d\n",memory[0]);
  printf("pointer to memory:    %p\n",*memory);
  
  *memory = 0x222471;
  printf("foreign memory:       %d\n",memory[0]);
  printf("pointer to memory:    %p\n",*memory);
  
  memory[0] = 12;
  printf("foreign memory:       %d\n",memory[0]);
  
  return 0;
}

