disaste0_0 2022-10-15 06:44 采纳率: 81.6%
浏览 222
已结题

怎么才能修复编译器错误 C2198

编译器错误 C2198

#include<stdio.h>
#include"student.h"
int main()
{
// student 1

STUDENT lux = Createstudent(2003056789, "lux", "aa", "ren");
printf("NAME:%s\n", GetNameFromStudent(lux));


// student 2

STUDENT a = Createstudent(2004069876, "bb", "cc");
printf("NAME:%s\n", GetNameFromStudent(a));
printstudent(a);

// student 3

STUDENT b = Createstudent("2003081234-DD EE gg");
printf("NAME:%s\n", GetNameFromStudent(b));
printstudent(b);

// student 4
STUDENT c = Createstudent("2003074521-QQ RR YY");
printf("NAME:%s\n", GetNameFromStudent(c));
printstudent(c);

// student 5
STUDENT d = Createstudent("2003017623-MM NN JJ");
printf("NAME:%s\n", GetNameFromStudent(d));
printstudent(d);
return 0;

}

这个是我的头文件
#pragma once

#define MAXSIZE   25

typedef struct student
{
    int studentnum;
    char firstname[MAXSIZE];
    char lasttname[MAXSIZE];
    char middelname[MAXSIZE];
}STUDENT;


STUDENT Createstudent(int, char[], char[], char[]);
void printstudent(STUDENT);

这是另一个c文件
#define _CRT_SECURE_NO_WARNINGS
#include"student.h"
#include<stdio.h>
#include<string.h>

STUDENT Createstudent(int StudentNum, char lasttname[MAXSIZE], char firstname[MAXSIZE], char middelname[MAXSIZE])
{
    STUDENT s;
    s.studentnum = StudentNum;
    strncpy(s.lasttname, lasttname, MAXSIZE);
    strncpy(s.firstname, firstname, MAXSIZE);
    strncpy(s.middelname, middelname, MAXSIZE);
    
    return s;
}


void printstudent(STUDENT student)
{
    int i;
    for (i = 0; i < 5; i++)
    {
        if (student.middelname[i] = '\0') //this mean nothing on middlename
        {
            printf("%d-%s,%s", student.studentnum, student.lasttname, student.firstname);
        }
        else
        {
            printf("%d-%s,%c", student.studentnum, student.lasttname, student.firstname, student.middelname[0]);
        }
    }
}
编译器错误 C2198
我的解答思路和尝试过的方法
  • 写回答

2条回答 默认 最新

  • 浪客 2022-10-15 08:35
    关注

    STUDENT Createstudent(int, char[], char[], char[]); 4个形参
    调用时缺参数。
    STUDENT a = Createstudent(2004069876, "bb", "cc");
    STUDENT c = Createstudent("2003074521-QQ RR YY");
    还有,int最大装21开头的10位数,你的学号很容易超出范围。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录
    1人已打赏
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 10月24日
  • 已采纳回答 10月16日
  • 修改了问题 10月15日
  • 修改了问题 10月15日
  • 展开全部

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。