【发布时间】:2019-11-15 06:47:49
【问题描述】:
int main() {
string str[5] = "ABCD";
std::cout << str[3] << std::endl;
std::cout << str[0] << std::endl;
return 0;
}
此代码打印:
ABCD
ABCD
我没听懂,str[3] 是如何打印ABCD 的?
编译器:GCC 6.3
【问题讨论】:
-
你用的是什么编译器?据我所知,这不应该编译
-
你的问题是为什么不打印D和A,然后试试
char str[5] = "ABCD"; -
@Mat 这是来自codechef.com/ide的GCC 6.3。
-
@acraig5075 我的问题是我不明白 str[3] 是如何工作的?我的意思是它指向哪里?