1.char *str[] = { "Welcome", "to", "Fortemedia", "Nanjing" };
2.char **p = str + 1;
3.str[0] = (*p++)+2;
4.cout << str[0] << endl;
5.str[0] += 1 ;
6.cout << str[0] << endl;
7.str[0] += 1;
8.cout << str[0] << endl;
在VS2013中运行结果如下:
(空)
(空)
Fortemedia
请按任意键继续. . .
第三行str[0]指向o后面的'\0',输出为空,但是将指针加1后输出为什么还是空?再次加1才指向下一个字符串首地址。