计划招收 3 名学生详细信息和科目(3) 分数和
展示礼帽
一个分支下的学生。
错误是“topper”、“brnchwise”的类型冲突。
我在使用函数之前已经定义了它们。
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <stdlib.h>
struct student
{
int regno;
char brnch[3];
int marks[3];
int avg;
} s[3];
void mainscrn()
{
int o;
char brncho[3];
printf("enter 1. for displaying topper details\n\t 2.for display all students under a branch");
scanf("%d",&o);
switch(o)
{
case 1:
system("CLS");
printf("the topper details are:");
topper();
break;
case 2:
system("CLS");
printf("Enter the brnch");
scanf("%s",&brncho);
system("CLS");
brnchwise();
break;
default:
printf("pls enter a right option");
mainscrn();
break;
}
}
void topper()
{
int i,a,count,t=0;
for(i=0;i<3;i++)
{
if(s[i].avg>t)
{
count=i;
}
}
printf("regno:\t %d\nbranch:\t%s",s[count].regno,s[count].regno);
printf("\nPress 0 fo main screen");
scanf("%m",&a);
if(a==0)
{
mainscrn();
}
}
void brnchwise()
{
int a,i;
char brncho[3];
printf("the sudents are: \n");
scanf("%s",&brncho);
for(i=0;i<3;i++)
{
if(strcmp(brncho,s[i].brnch)==0)
{
printf("/n%s",s[i].regno);
}
}
printf("\nPress 0 fo main screen");
scanf("%m",&a);
if(a==0)
{
mainscrn();
}
}
int main()
{
int i,j,t;
for(i=0;i<3;i++)
{
printf("Enter your detils 1.regno,2.brnch,marks");
t=0;
scanf("%d%s",&s[i].regno,&s[i].brnch);
for(j=0;j<3;j++)
{
scanf("%d",&s[i].marks[j]);
t=t+s[i].marks[j];
}
s[i].avg=t;
}
mainscrn();
return 0;
}
最佳答案
I've defined functions before using them.
事实上,你没有。 topper
和 brnchwise
在 mainscrn
中引用,但此时它们尚未定义。由于这些函数相互引用,因此您需要为这些函数添加声明:
void topper(void);
void brnchwise(void);
void mainscrn(void)
{
...
}
void topper(void)
{
...
}
void brnchwise(void)
{
...
}
关于 'topper' 的冲突类型,brnchwise,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31477288/