다음 코드 버그 좀 잡아주세요 ..(짧음 ^^)

하하의 이미지

제목과 같습니다 ㅋ

#include <stdlib.h>

main()
{
    char    **phone_number;
    int     i;

    phone_number = (char **)malloc(10);


    for(i=0 ; i < 10 ; i++ )
    {
        phone_number[i] = (char *)malloc(1024);
    }



    for(i=0 ; i < 10 ; i++ )
    {
        free(phone_number[i]);
    }

    free(phone_number);
}
new5244의 이미지

phone_number = (char **)malloc(10);
==>

phone_number = (char **)malloc(10 * sizeof(char *) );

from saibi