次の C コードでは:
char test[] ={'T','e','s','t'};
printf("%d\n",test == &test[0]); // Returns 1 - Okay as array varaible holds address of first element
したがって、以下は同じように出力されるべきではありませんか?:
printf("value of test %c\n", test); // prints - '|' not even in the array
printf("value of test[0] %c\n", test[0]); // prints - 'T'
それどころか、これらでも異なる値が出力されます。
printf("value of test %p\n", test); // contains a address 0x7ffee9b22b7c
printf("value of test[0] %p\n", test[0]); // also conatains 0x100
何が起こっている?
ありがとう