7.62口径 自助:指针指向字符串后的地址问题?

来源:百度文库 编辑:高校问答 时间:2024/05/04 13:42:19
请看下面一个小程序:
#include <iostream>
#include <string.h>
using namespace std;
int main()
{
char string1[]="no man is an island";
char * pr=string1;
cout<<"the string address is:"<<string<<endl;
cout<<"the true string address is:"<<&string<<ensl;
cout<<"the pr is:"<<pr<<endl;
cout<<"the *pr is:"<<*pr<<endl;
return 0;
}
问题1:为什么cout<<"the string address is:"<<string<<endl;的输出结果不是地址而是内容,string难道不代表一个数组的首地址吗?
问题2:为什么cout<<"the pr is:"<<pr<<endl;输出的不是地址,pr是一个指针变量,里面保存的难道不是地址吗?