yaotti's diary

Software is Eating the World

2008-05-04から1日間の記事一覧

この2つの違い

c ?

char tmp1[10]; char *tmp2 = malloc(10); tmp1は長さMAXNUM(cは1つ1バイトなのでMAXNUMバイト)の配列 tmp2はMAXNUMバイトの領域を指すポインタ printf("%d\n", sizeof(tmp1)); printf("%d\n", sizeof(*tmp2)); 結果は前者は10、後者は1。 tmp2はまだ領域を…