'topper' 的冲突类型,brnchwise

标签 c structure

计划招收 3 名学生详细信息和科目(3) 分数和

  1. 展示礼帽

  2. 一个分支下的学生。

错误是“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.

事实上,你没有。 topperbrnchwisemainscrn 中引用,但此时它们尚未定义。由于这些函数相互引用,因此您需要为这些函数添加声明:

void topper(void);
void brnchwise(void);

void mainscrn(void)
{
    ...
}

void topper(void)
{
    ...
}

void brnchwise(void)
{
    ...
}

关于 'topper' 的冲突类型,brnchwise,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31477288/

相关文章:

c - 在 C 中释放分配的内存时堆损坏

c - 为指向结构数组的指针动态分配内存

matlab - 字段内的结构

c - 对于结构变量s1,s2,为什么我可以初始化 "s1={25,3.5}",将s2赋值为 "s1=s2",然后就不能使用“s1={59,3.14}?

ios - PjSip 添加多个 header

c++ - 为什么 MSVC 大发脾气编译宏,而 G++ 是关于禅宗的?

c - strcmp 和 fscanf 带 While 循环遍历文件

c - fgets 没有得到最后一个字符

c - error : conflicting types, 错误:形参2的类型不完整

c - 在结构中声明匿名结构有什么用?