zoukankan      html  css  js  c++  java
  • 字符串取地址

    #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;输出的事整个字符串
     
  • 相关阅读:
    2-5
    2-4 及 1、2两章 学习心得 和问题
    2-3
    4-8
    4-6
    4-5
    4-4
    4-3
    4-2
    4-1
  • 原文地址:https://www.cnblogs.com/8335IT/p/5918299.html
Copyright © 2011-2022 走看看