叮当猫手机主题:C语言高手进!帮我看下这个函数哪里错了?

来源:百度文库 编辑:神马品牌网 时间:2024/04/29 05:13:42
void menu2()
{
int i;
char j;
i=check();
i++;
printf("please input the name of the student:\n");
scanf("%s",&name[i]);
printf("please input the number of the student:\n");
scanf("%d",&num[i]);
printf("please input the mark of the maths:\n");
scanf("%d",&mat[i]);
printf("please input the mark of the C program:\n");
scanf("%d",&cpr[i]);
sco[i]=mat[i]+cpr[i];
printf("continue?(y\\n)\n");
j=getchar();
if(j=='n') goto end1;
else menu2();
end1:
}
那些数组都是全局的变量,name是二维的数组~
帮忙啊,他就说是顶上那行语法表达错误~可是错在哪里?
check();
是另外一个函数,计算数组中元素的数量的~
这个肯定没错

都不知道~还在编程混~拷

void menu2()
{
int i;
char j;
i=check();
//改成循环
while(j=='y')
{

i++;
printf("please input the name of the student:\n");
scanf("%s",&name[i]);
printf("please input the number of the student:\n");
scanf("%d",&num[i]);
printf("please input the mark of the maths:\n");
scanf("%d",&mat[i]);
printf("please input the mark of the C program:\n");
scanf("%d",&cpr[i]);
sco[i]=mat[i]+cpr[i];
printf("continue?(y\\n)\n");
j=getchar();
}
}

你看看是不是你这个程序上边的程序缺少}等啊

当二维数组只带一个下标时,本身就是表示地址.
scanf("%s",&name[i]); 这行有错,把&name[i]前面的&去掉.
另外,最好在每一句scanf后面都加上一句getchar();,把回车字符吃掉.

结构化编程最好不要用goto。你的错误应该是上面的函数的问题。而且你的函数最好用循环,不要用递归,因为没有必要用递归。