C语言问题,求大神解答cannot convert parameter 1 from 'char [100][100]' to 'char [][14]'的错误
#include<stdio.h>#include<conio.h>#include<string.h>/*输入学号查询成绩*/voidfound1(charID[100...
#include<stdio.h>
#include<conio.h>
#include<string.h>
/*输入学号查询成绩*/
void found1(char ID[100][14],char name[100][100],int Chinese[100],int Math[100],int English[100],int s){
int i=0;
int sum;
char str1[1][14];
printf("请输入你要查询的学号\n");
gets(str1[1]);
do{
if(strcmp(ID[i],str1[1])==0){
printf("学生姓名为:");
puts(name[i]);
printf("学生学号为:");
puts(ID[i]);
printf("学生语文成绩为:");
printf("%d",Chinese[i]);
printf("学生数学成绩为:");
printf("%d",Math[i]);
printf("学生英语成绩为:");
printf("%d",English[i]);
sum=Chinese[i]+Math[i]+English[i];
printf("该学生总成绩为%d\n",sum);
}
i++;
} while (i<s);
}
void main(){
int a;
int i=0;
char name[100][100],ID[100][14];
int Chinese[100],Math[100],English[100],s;
do{
gets(name[i]);
printf("输入第%3d学生的姓名:\n", i+1);
gets(name[i]);
printf("输入第%3d学生的学号:\n", i+1);
gets(ID[i]);
printf("输入第%3d学生的语文成绩:\n", i+1);
scanf("%d",&Chinese[i]);
printf("输入第%3d学生的数学成绩:\n", i+1);
scanf("%d", &Math[i]);
printf("输入第%3d学生的英语成绩:\n", i+1);
scanf("%d", &English[i]);
i++;
printf("继续请按1,停止输入请按0,按回车键结束");
scanf("%d", &a);
} while (a);
s=i;
found1(name,ID,Chinese,Math,English,s);
getch();
}
总出现
error C2664: 'found1' : cannot convert parameter 1 from 'char [100][100]' to 'char [][14]'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
的错误提示怎么办。 展开
#include<conio.h>
#include<string.h>
/*输入学号查询成绩*/
void found1(char ID[100][14],char name[100][100],int Chinese[100],int Math[100],int English[100],int s){
int i=0;
int sum;
char str1[1][14];
printf("请输入你要查询的学号\n");
gets(str1[1]);
do{
if(strcmp(ID[i],str1[1])==0){
printf("学生姓名为:");
puts(name[i]);
printf("学生学号为:");
puts(ID[i]);
printf("学生语文成绩为:");
printf("%d",Chinese[i]);
printf("学生数学成绩为:");
printf("%d",Math[i]);
printf("学生英语成绩为:");
printf("%d",English[i]);
sum=Chinese[i]+Math[i]+English[i];
printf("该学生总成绩为%d\n",sum);
}
i++;
} while (i<s);
}
void main(){
int a;
int i=0;
char name[100][100],ID[100][14];
int Chinese[100],Math[100],English[100],s;
do{
gets(name[i]);
printf("输入第%3d学生的姓名:\n", i+1);
gets(name[i]);
printf("输入第%3d学生的学号:\n", i+1);
gets(ID[i]);
printf("输入第%3d学生的语文成绩:\n", i+1);
scanf("%d",&Chinese[i]);
printf("输入第%3d学生的数学成绩:\n", i+1);
scanf("%d", &Math[i]);
printf("输入第%3d学生的英语成绩:\n", i+1);
scanf("%d", &English[i]);
i++;
printf("继续请按1,停止输入请按0,按回车键结束");
scanf("%d", &a);
} while (a);
s=i;
found1(name,ID,Chinese,Math,English,s);
getch();
}
总出现
error C2664: 'found1' : cannot convert parameter 1 from 'char [100][100]' to 'char [][14]'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
的错误提示怎么办。 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询