【发布时间】:2019-02-23 19:17:21
【问题描述】:
我对 char 数组的内存地址感到困惑。以下是演示代码:
char input[100] = "12230 201 50";
const char *s = input;
//what is the difference between s and input?
cout<<"s = "<<s<<endl; //output:12230 201 50
cout<<"*s = "<<*s<<endl; //output: 1
//here I intended to obtain the address for the first element
cout<<"&input[0] = "<<&(input[0])<<endl; //output:12230 201 50
char 数组本身是一个指针吗?为什么 & 运算符不给出 char 元素的内存地址?如何获取各个条目的地址?谢谢!
【问题讨论】:
标签: c++