#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;输出的事整个字符串
字符串取地址

 

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-12
猜你喜欢
  • 2021-08-14
  • 2022-12-23
  • 2021-08-18
  • 2021-09-26
  • 2021-08-30
相关资源
相似解决方案