char *a[10] = {"Fortran","Basic","pascal","C","C++"};
a[10]不是应该是指针数组么。为什么这么写呢?应该存放着char*类型的呀,为什么是char类型的呢?...
a[10]不是应该是指针数组么。
为什么这么写呢?
应该存放着char * 类型的呀,为什么是char类型的呢? 展开
为什么这么写呢?
应该存放着char * 类型的呀,为什么是char类型的呢? 展开
展开全部
char *a[10]
[ ] 优先级高于 *
所以这是一个数组
数组的元素类型是 char *
即字符型指针,指向字符串
char *a[10] = {"Fortran","Basic","pascal","C","C++"};
a[0] = "Fortran"; a[1] = "Basic"; ...............
不是 char
如果是char
char a[3] = { 'a', 'b', '\0'};
类同 char a[3] = "ab";
[ ] 优先级高于 *
所以这是一个数组
数组的元素类型是 char *
即字符型指针,指向字符串
char *a[10] = {"Fortran","Basic","pascal","C","C++"};
a[0] = "Fortran"; a[1] = "Basic"; ...............
不是 char
如果是char
char a[3] = { 'a', 'b', '\0'};
类同 char a[3] = "ab";
追问
按照上面定义的,*a[0]是不是 "F"
追答
是的 *a[0] ,a[0][0] 都是 F
char *a[10] = {"Fortran","Basic","pascal","C","C++"};
如果这样初始化, 就不能去修改字符串。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询