Last active
August 29, 2015 14:05
-
-
Save jouyouyun/fda5408525c6c55d8cd5 to your computer and use it in GitHub Desktop.
Test malloc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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