このコードで y を読み取った後に text1 の値が変わるのはなぜですか?
void func()
{
int value1 = 5;
double value2 = 1.5;
std::ostringstream x, y;
x << value1;
y << value2;
const char *text1 = x.str().c_str();
fprintf(stderr, "text1: v=%s, p=%p\n", text1, &text1);
const char *text2 = y.str().c_str();
fprintf(stderr, "text1: v=%s, p=%p\ntext2: v=%s, p=%p\n", text1, &text1, text2, &text2);
}
出力:
text1: v = 5、a = 0xbfcfd508
テキスト 1: v = 1.5、a = 0xbfcfd508
text2: v = 1.5、a = 0xbfcfd510