C -- 字符串数组与字符串指针

// 定义

char str[4][20] = {"one", "two", "three", "four"};

char str2[][20] = {"one", "two", "three", "four"};

char *str3[4] = {"one", "two", "three", "four"};

char *str4[] = {"one", "two", "three", "four"};

// 遍历

int length = sizeof(str3) / sizeof(str3[0]);

for(int i = 0; i < length; i++){

    printf("%s ", str3[i]);

}

printf("\n");

posted @ 2016-01-21 13:51  以神之名  阅读(248)  评论(0编辑  收藏  举报