/* malloc */
#include <malloc.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define BUFFER_SIZE 1000
char* alloc_mem(void)
{
char *temp = (char*) malloc(BUFFER_SIZE);
if (temp == NULL) {
printf("Memory allocation error");
exit(1);
}
return temp;
}
int main()
{
char *tm = alloc_mem();
strcpy(tm,"Hello world");
printf("%s\n",tm);
printf("%d\n",alloc_mem());
printf("%d\n",alloc_mem());
return 0;
}