鱼C论坛

 找回密码
 立即注册
查看: 2692|回复: 5

redefinition; different basic types错误

[复制链接]
发表于 2017-12-30 11:22:34 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
调用函数#include<stdio.h>
struct student
{
        int xuehao;
        char name[29];
        double chengji[5];
};
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[j].xuehao,p[j].name,&p[j].chengji[0],&p[j].chengji[1],&p[j].chengji[2],&p[j].chengji[3],&p[j].chengji[4]);

        }
        for (j=0;j<k;j++)
        {
                for (i=0;i<k-j;i++)
                {
                        if (p[i-1].xuehao>p[i].xuehao)
                        {
                                t[i]=p[i-1];
                                p[i-1]=p[i];
                                p[i]=t[i];
                        }
                }
        }
        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[j].xuehao,b[j].name,b[j].chengji[0]);
                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);
}
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2017-12-30 11:29:35 | 显示全部楼层
错误截完整点
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2017-12-31 12:53:08 From FishC Mobile | 显示全部楼层
本帖最后由 sp1ral 于 2017-12-31 13:06 编辑

t=(struct student *)malloc(100*sizeof(struct student *))
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2017-12-31 12:55:14 From FishC Mobile | 显示全部楼层
本帖最后由 sp1ral 于 2017-12-31 13:08 编辑

错误提示
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2017-12-31 13:14:35 From FishC Mobile | 显示全部楼层
#include"malloc.h"    malloc()函数被包含在malloc.h里面
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2017-12-31 13:23:00 From FishC Mobile | 显示全部楼层
unsigned int num;void input(int k, struct student *p)  参数类型不同
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-10-1 07:42

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表