我从这里了解到,数组的名称是数组中第一个元素的地址,所以这对我来说很有意义:
int nbrs[] = {1,2};
cout << nbrs << endl; // Outputs: 0x28ac60
Run Code Online (Sandbox Code Playgroud)
但是,为什么整个C字符串返回此处而不是地址ltrs
?
char ltrs[] = "foo";
cout << ltrs << endl; // Outputs: foo
Run Code Online (Sandbox Code Playgroud) c++ ×1