• 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 }

  • 相关阅读:
    hdu1875(最小生成树prime)
    hdu1839(最小生成树)
    poj2739(尺取法+质数筛)
    poj2100(尺取法)
    codeforces-div2-449-B
    gym-101350M
    gym-10135I
    gym-101350H
    gym-101350D
    hdu 5569
  • 原文地址:https://www.cnblogs.com/wujufengyun/p/6970342.html
Copyright © 2020-2023  润新知