main関数の最後の行で、なぜとは&word2
違うのword2
ですか?正しいヘッダーが配置されていると仮定します。ありがとうございました!
int main()
{
char word1[20];
char *word2;
word2 = (char*)malloc(sizeof(char)*20);
printf("Sizeof word 1: %d\n", sizeof (word1));
printf("Sizeof word 2: %d\n", sizeof (word2));
strcpy(word1, "string number 1");
strcpy(word2, "string number 2");
printf("%s\n", word1);
printf("%s\n", word2);
printf("Address %d, evaluated expression: %d\n", &word1, word1);
printf("Address %d, evaluated expression: %d\n", &word2, word2);
//Why this one differ?
}