#include <stdio.h>
#include <stdlib.h>
int main(void)
{
char *p, *saved_p;
p=(char *)malloc(30*sizeof(char));
strcpy(p, "test1");
printf("%s\n", p);
saved_p = p;
p=(char *)malloc(30*sizeof(char));
strcpy(p, "test2");
printf("%s\n", p);
printf("%s\n", saved_p);
free(p);
return 1;
}
free()ÇØÁÖÁö ¾ÊÀ¸¸é ¸Þ¸ð¸® »ó¿¡ ±âÁ¸ÀÇ °ªÀÌ ³²¾ÆÀÖ°Ô µÇ´Â°Ô ¸Â½À´Ï´Ù.
ÀÌ·¸°Ô ±âÁ¸ÀÇ ÁÖ¼Ò¸¦ ÀúÀåÇØ ³õÀº ´ÙÀ½¿¡ ±× ÁÖ¼Ò¸¦ Ãâ·ÂÇغ¸¸é
½±°Ô ¾Ë ¼ö ÀÖ°ÚÁÒ.
[root@hackerschool root]# ./test
test1
test2
test1
[root@hackerschool root]#
|