Skip to content

Instantly share code, notes, and snippets.

@jouyouyun
Last active August 29, 2015 14:05
Show Gist options
  • Save jouyouyun/fda5408525c6c55d8cd5 to your computer and use it in GitHub Desktop.
Save jouyouyun/fda5408525c6c55d8cd5 to your computer and use it in GitHub Desktop.
Test malloc
#include <stdio.h>
#include <stdlib.h>
int
main ()
{
int *p;
p = (int*)malloc(sizeof(int));
if (p == NULL) {
printf("Unable to alloc memory\n");
return -1;
}
*p = 10;
printf("%d\n", *p);
free(p);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment