#include <iostream> #include<string> #include <cstring> #include<vector> #include<sstream> #include<algorithm> #include <stdlib.h> #include <stdio.h> using namespace std; int main() { char *p="fdg"; cout<<*(p+1)<<endl;;//p所指的位置是不变的与p++不同 cout<<*p<<endl; cout<<p<<endl; cout<<&p<<endl;//指针所在的地址 cout<<static_cast<const void *>(p)<<endl;//必须要转化成无类型指针,输出的是字符串首地址 string str="gjjlhklj"; cout<<str<<endl; cout<<&str<<endl; cout<<&str[0]<<endl; cout<<static_cast<const void *>(&str[0])<<endl; }
cout<<&str[0]<<endl;输出的事整个字符串