【发布时间】:2010-08-22 03:46:37
【问题描述】:
我正在编写一个需要输入文本并修改单个字符的程序。我通过使用一个字符数组来做到这一点,就像这样:
char s[] = "test";
s[0] = '1';
cout << s;
(Returns: "1est")
但如果我尝试使用变量,像这样:
string msg1 = "test";
char s2[] = msg1;
s2[0] = '1';
cout << s1[0]
我收到一个错误:error: initializer fails to determine size of 's2'
为什么会这样?
【问题讨论】: