07/10/19 13:22:06
>>209
文字列リテラルを使うときに、メモリを節約できるから。
つまり、次のコードは、同じ値を出力するかもしれない。
# コンパイラとオプションによって変わる
--
void exsample()
{
const char * foo = "abcde";
const char * bar = "abcde";
printf("%p, %p\n", foo, bar);
}
--
勿論、次のコードは只の配列だから違う値が出力される。
void exsample2()
{
char foo[] = "abcde";
char bar[] = "abcde";
printf("%p, %p\n", foo, bar);
}