干戈寥落 发表于 2017-12-30 11:22:34

redefinition; different basic types错误

调用函数#include<stdio.h>
struct student
{
        int xuehao;
        char name;
        double chengji;
};
void input(int k, struct student *p)
{
        int j,i,max,o;
        double *v;
        struct student *t;
        v=(double *)malloc(100*sizeof(double *));
        t=(struct student *)malloc(100*sizeof(struct student *));
        printf("%s%s %s %s %s %s %s\n","学号","姓名","英语","高数","马哲","计算机","电子技术");
        for (j=0;j<k;j++)
        {
                scanf("%d %s %lf %lf %lf %lf %lf",&p.xuehao,p.name,&p.chengji,&p.chengji,&p.chengji,&p.chengji,&p.chengji);

        }
        for (j=0;j<k;j++)
        {
                for (i=0;i<k-j;i++)
                {
                        if (p.xuehao>p.xuehao)
                        {
                                t=p;
                                p=p;
                                p=t;
                        }
                }
        }
        PrintScoreeg(k,p);
}
被调用函数void PrintScoreeg(int a,struct student *b)
{
        int j;
        printf("\n");
        printf("课程名称:英语\n");
        printf("——————————————\n");
        printf("%s\t%s\t%s\n","学号","姓名","英语");
        printf("\n");
        printf("——————————————\n");
        for (j=0;j<a;j++)
        {
                printf("%d\t%s\t%lf",b.xuehao,b.name,b.chengji);
                printf("\n");
        }
}
主函数
void main()
{
        struct student *s;
        unsigned int num;
        printf("请输入学生的个数\n");
        scanf("%d", &num);
        s=(struct student *)malloc(100*sizeof(struct student *));
        printf("请输入学生信息\n");
        input(num,s);
        free(s);
}

micheal1 发表于 2017-12-30 11:29:35

错误截完整点

sp1ral 发表于 2017-12-31 12:53:08

本帖最后由 sp1ral 于 2017-12-31 13:06 编辑

t=(struct student *)malloc(100*sizeof(struct student *))

sp1ral 发表于 2017-12-31 12:55:14

本帖最后由 sp1ral 于 2017-12-31 13:08 编辑

错误提示

sp1ral 发表于 2017-12-31 13:14:35

#include"malloc.h"    malloc()函数被包含在malloc.h里面

sp1ral 发表于 2017-12-31 13:23:00

unsigned int num;void input(int k, struct student *p)参数类型不同
页: [1]
查看完整版本: redefinition; different basic types错误