//-----------------------------------------------------------------------------
// memoryErrorsII.c
//
// program will demonstrate the dynamic use of memory
// it shows problems that valgrind can display
//
// 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. 
///
/// generate erros :-)
/// 
///  @return int  always zero 
// 
int main()
{
  int *memory = NULL;
  
  memory = malloc(sizeof(int));
  memory[0] = 'c';
  printf("%c\n",memory[0]);
  
  free(memory);
  
  memory = malloc(4); //size needn't to be a function
  memory[0] = 'c';
  printf("%c\n",memory[0]);
  
  memory = 'c';
  printf("%c\n",memory[0]);
  
  free(memory);  //only free memory behind last position
  
  return 0;
}
