老兄能否听我一言:
#include <iostream.h>
#include <string.h>
int main(int argc, char* argv[])
{
char *str1="shediao";
char *str2=str1;
cout<<(unsigned *)str1<<endl;
cout<<&str1<<endl;
cout<<(unsigned *)str2<<endl;
cout<<&str2<<endl;
return 0;
}
结果:
0x00429108
0x0012FF7C
0x00429108
0x0012FF78
所以输出字符串的地址应该为cout<<(unsigned*)str1;
而 cout<<&str1;是指输出了指针变量的地址