使用VC2008.
#include<iostream>
using namespace std;
int main()
{
cout<<"hello"[0]<<"hello"[1]<<"hello"[2]<<"hello"[3]<<"hello"[4]<<"的长度是:"<<sizeof("hello")<<endl;
cout<<"hello[0]的地址是:"<<&"hello"<<endl;
cout<<"hello[1]的地址是:"<<&("hello"+1)<<endl;
const char *p=&"xhello"[1];
cout<<p<<endl;
return 1;
}
输出结果:
hello的长度是:6
hello[0]的地址是:00247878
hello[1]的地址是:00247879
hello