a[4] = c;
a[3] = c;
请画内存图
#include <stdio.h> int main() { char *a[5]; char b[10] = "lilei"; char c[10]; char d = 'm'; char **p = a; a[0] = "hello"; a[1] = (char*)malloc(5); //安全检查。。 a[2] = b; a[3] = c; a[4] = &d; strcpy(a[1],"bye"); strcpy(a[3],a[2]); for(i = 0;i<4;i++) { printf("a[%d] : %s\n",i,a[i]); printf("a[%d] : %s\n",i,p[i]); printf("a[%d] : %s\n",i,*(p+i)); } printf("a[4]:%c\n",*a[4]); printf("a[4]:%c\n", *(*(p+4)) ); }
原文地址:http://blog.csdn.net/xiaoliu0518/article/details/33333525