代码
#include<stdio.h>
main()
{
//字符串数组 可修改
char ch1[] = "hello";
char ch2[] = "world";
char ch3[] = "dabaobei";
char* arr[] = { ch1,ch2,ch3 };
//字符串数组 不可修改
char* ar[] = { "hello","world","dabaobei" };
for (int i = 0; i < 3; i++) {
printf("%s\t", ar[i]); // 打印数组中所有字符串
}
printf("\n");
for (int j = 0; j < 3; j++) {
printf("%c\t", ar[j][0]);// 打印数组中字符串的首字母
}
return 0;
}
结果
hello world dabaobei
h w d