#include <stdio.h>
#include <stdlib.h>
#include
<string.h>
#include <unistd.h>
int main(int argc, char **argv)
{
/*
这个是给str分配存储字符串地址的空间 */
char **str =
(char**)malloc(sizeof(char*)*256);
/*
这个是给str分配str中的地址所指向的字符串存储空间的大小 */
*str =
(char*)malloc(sizeof(char)*256);
/* 备份二级指针的首地址
*/
char **strbak = str;
*str = "aaa";
/* 打印地址
*/
printf ("addr-str=%p\n", str);
/*
打印aaa*/
printf ("*str=%s\n", *str++);
*str = "bbb";
printf
("addr-str=%p\n", str);
printf ("*str=%s\n", *str++);
*str = "ccc";
printf
("addr-str=%p\n", str);
printf ("*str=%s\n", *str++);
*str = malloc(32);
printf
("*str=%s\n", *str);
/* 直接拷贝会报段错误 */
strcpy (*str, "ddd");
printf ("sizeof *str=%d\n",
sizeof(*str));
printf ("addr-str=%p\n",
str);
printf ("*str=%s\n", *str++);
int i;
for (i=0; i<4;
i++)
{
printf ("*strbak=%s\n", *strbak++);
}
return 0;
}