C--二维数组、指针数组、数组指针(字符串简单举例)
程序代码 #include "stdio.h" #include "stdlib.h" #include "string.h" /* 二维数组表示方法如下 1.数组名 2.指针数组 3.数组指针(只能用来存储二维数组的数组名[即二维数组的首地址],不可用来存储内容) */ // 二维数组 // ① char testStr1[10][6] = {"begin", "ifgbd", "while", "dosfa", "abend"}; // 字符串的存储方式 1.字符数组 2.字符指针变量 char testStr1[10][5] = {{'b','e','g','i','n'}, {'i','f','g','b','d'}, {'w','h','i','l','e'}, {'d','o','s','f','a'}, {'a','b','e','n','d'}}; /* 注意: char str1[10] = {'s','t','u','d','e','n','t'}; 在内存中的存放形式为: s t u d e n t 【6】 char str2[10] = "student"; // 在存储字符串时末尾自动加上字符串的结束标志'\0' 在内存中的存放形式为: s t u d e n t \0 【7】这是为什么前面 testStr1[10][6] 要这样定义