二、代码
#include <stdio.h>
int main()
{
/*
char str1[] = "lyh";
char str2[] = "lys";
char str3[] = "lyt";
char str4[] = "lyx";
char strs[4][20] =
{
"lyh",
"lys",
"lyt",
"lyx"
};
*/
char str1[] = "lyh";
char str2[] = "lys";
char str3[] = "lyt";
char str4[] = "lyx";
// 定义数组的格式 : 元素类型 数组名称[元素的个数]
int a = 10;
int b = 20;
int nums[2] = {10,20};
char *names[4] =
{
"lyh",
"lys",
"lyt",
"lyx"
};
for (int i = 0; i < 4; i++) {
printf("names[%i] = %s\n",i,names[i]);
}
return 0;
}