typedef struct _sData

{

char *str1;

char *str2;

} DATA, *PDATA;


void main ( )

{

DATA data1={"abc","ABC"}, data2={"def","DEF"};

char temp[100];

printf("%s %s\n", data1.str1, data1.str2);

printf("%s %s\n", data2.str1, data2.str2);


memset(temp, 0 , sizeof(char)*100);

gets(temp);

data1.str1 = (char*)malloc(strlen(temp)+1);

strcpy(data1.str1, temp);


memset(temp, 0 , sizeof(char)*100);

gets(temp);

data1.str2 = (char*)malloc(strlen(temp)+1);

strcpy(data1.str2, temp);

printf("%s %s\n", data1.str1, data1.str2);

}


보면 malloc 두번하는데


free는 한번도 안하네


원래 malloc 한번 하면 free도 한번


두번하면 두번 해야 되는거 아님?