马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
书上是这么赋值的#include<stdio.h>
int main(void){
char *cBooks[]={
"《C程序设计语言》",
"《C专家编程》",
"《C和指针》",
"《C陷阱和缺陷》",
"《C Primer Plus》",
"《带你学C带你飞》"
};
char **byFishC;
char **jiayuLoves[4];
int i;
byFishC=&cBooks[5];
jiayuLoves[0]=&cBooks[0];
jiayuLoves[1]=&cBooks[1];
jiayuLoves[2]=&cBooks[2];
jiayuLoves[3]=&cBooks[3];
printf("FishC出版的图书有:%s\n",byFishC);
printf("小甲鱼喜欢的图书有:\n");
for (i=0;i<4;i++){
printf("%s\n",*jiayuLoves[i])
}
}
我是这么赋值的#include<stdio.h>
int main(void){
char *cBooks[]={
"《C程序设计语言》",
"《C专家编程》",
"《C和指针》",
"《C陷阱和缺陷》",
"《C Primer Plus》",
"《带你学C带你飞》"
};
char **byFishC;
char **jiayuLoves[4];
int i;
byFishC=&cBooks[5];
jiayuLoves={&cBooks[0],&cBooks[1],&cBooks[2],&cBooks[3]};
//为什么上一行不可以这样写,jiayuLoves不是一个数组吗,用数组的赋值方式不行吗
printf("FishC出版的图书有:%s\n",*byFishC);
print("小甲鱼喜欢的图书有:\n");
for(i=0;i<4;i++){
printf("%s\n",*jiayuLoves[i]);
}
}
我写的那个报错了,为什么不能用数组赋值的方式给指针的指针数组赋值呢?test4_6_1.c: 在函数‘main’中:
test4_6_1.c:17:13: 错误:expected expression before ‘{’ token
jiayuLoves={&cBooks[0],&cBooks[1],&cBooks[2],&cBooks[3]};
^
#include <stdio.h>
int main(void) {
char *cBooks[] = {
"《C程序设计语言》", "《C专家编程》",
"《C和指针》", "《C陷阱和缺陷》",
"《C Primer Plus》", "《带你学C带你飞》"
};
char **byFishC;
char **jiayuLoves[4] = {&cBooks[0], &cBooks[1], &cBooks[2], &cBooks[3]};
int i;
byFishC = &cBooks[5];
printf("FishC出版的图书有:%s\n", *byFishC);
//print("小甲鱼喜欢的图书有:\n"); // ?????????
printf("小甲鱼喜欢的图书有:\n");
for(i = 0; i < 4; i++) {
printf("%s\n", *jiayuLoves[i]);
}
return 0;
}
|