malloc() are my comments correct
/* First of all am I right in thinking that malloc(10) in the program */
/* below could be malloc(6) hello + '\0' = 6 and if so whats the */
/* reason for malloc(10), secondly could I have something like */
/* malloc(amount) if I declared a variable int amount; then did */
/* printf("Input amount of numbers to be stored"); */
/* scanf("%d",&amount); */
/* Finally this memory has to be freed before the program terminates */
/* to avoid a memory leak, what is and what does a memory leak do */
#include <stdio.h>
#include <string.h>
#include <alloc.h>
#include <process.h>
#include<conio.h>
int main(void)
{
char *str;
/* allocate memory for string */
if ((str = (char *) malloc(10)) == NULL)
{
printf("Not enough memory to allocate buffer\n");
exit(1); /* terminate program if out of memory */
}
/* copy "Hello" into string */
strcpy(str, "Hello");
/* display string */
printf("String is %s\n", str);
/* free memory */
free(str);
return 0;
}