// answer to task 5 of assignment 6

#include <stdio.h>

// first mistake: to use malloc, we must include stdlib.h
#include <stdlib.h> // correction

int main()
{
  char * my_string = (char *) malloc(sizeof(char) * 6);

  my_string[0] = 'h';
  my_string[1] = 'e';
  my_string[2] = 'l';
  my_string[3] = 'l';
  my_string[4] = 'o';

  // second mistake: using '0' instead of the null character,
  // which is either 0 (without quotes around it), or '\0'.
  //my_string[5] = '0';
  my_string[5] = 0; // correction.
  //my_string[5] = '\0'; // another possible correction.
  
  printf("my_string = %s\n", my_string);

  // third mistake: we should free my_string at the end
  free(my_string); // correction
}
