zoukankan      html  css  js  c++  java
  • char* str 和char str()

     1 #include<iostream>
     2 using namespace std;
     3 
     4 int main()
     5 {
     6     char *str = "abb";
     7     //*(str + 1) = 'c';
     8     cout << "输出str:" <<(void *) str << endl;
     9     cout << "输出 *str:" << *str << endl;
    10     cout << "输出 *(str+1):" << *(str+1) << endl;
    11     cout << "输出 str[1]:" << str[1] << endl;
    12     cout << "输出strlen(str):" << strlen(str) << endl;
    13     //cout << "输出strlen(*str):" << strlen(*str) << endl;
    14     cout << "输出sizeof(str):" << sizeof(str) << endl;
    15     cout << "输出sizeof(*str):" << sizeof(*str) << endl;
    16     char * index = str + 3;
    17     cout << "输出str:" << (void *)index << endl;
    18     if (index > str)
    19         cout << "right" << endl;
    20     else
    21         cout << "wrong" << endl;
    22     cout << "*****************************************" << endl;
    23     char str1[] = "abb";
    24     str1[1] = 'c';
    25     cout << "输出str1:" << (void*)(str1) << endl;
    26     cout << "输出 *str1:" << *str1 << endl;
    27     cout << "输出 *(str1+1):" << *(str1 + 1) << endl;
    28     cout << "输出 str1[1]:" << str1[1] << endl;
    29     cout << "输出strlen(str1):" << strlen(str1) << endl;
    30     //cout << "输出strlen(*str):" << strlen(*str) << endl;
    31     cout << "输出sizeof(str1):" << sizeof(str1) << endl;
    32     cout << "输出sizeof(*str1):" << sizeof(*str1) << endl;
    33     system("pause");
    34     return 0;
    35 }

  • 相关阅读:
    BFS模板 + 力扣例题
    和小吴日常3
    和小吴日常2
    Cocos Creator 学习记录
    js浏览器事件循环机制
    vue+uniapp 项目中一些常用知识
    JSP第一次作业
    Test
    InnoDB存储引擎
    MySQL存储引擎
  • 原文地址:https://www.cnblogs.com/wujufengyun/p/6970342.html
Copyright © 2011-2022 走看看