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 }

posted on 2017-06-09 09:17  无惧风云  阅读(705)  评论(0编辑  收藏  举报