vaghxc 2023-12-23 16:05 采纳率: 88.2%
浏览 4
已结题

求答疑 不显示输出结果

想知道为什么输入数据之后没有显示输出结果?是输入的格式不对吗?还是调用不对呢??
题目,输出结果和代码都在下面

img

img

#include<stdio.h>
struct grade                           
{                                     
    int num;
    char name;
    int score[3];
};
struct grade student[5];
char print(struct grade student[],int a)   
{
    printf("输出结果为:\n");
    for(int i=0;i<a;i++)
    {
        printf("%d ",student[i].num);
        printf("%s",student[i].name);
        printf("%d %d %d",student[i].score[0],student[i].score[1],student[i].score[2]);
        printf("\n");
    }
}
int main()
{
    printf("请输入记录:");
    for(int i=0;i<5;i++)
    {
        scanf("%d",&student[i].num);
        scanf("%s",student[i].name);          
        scanf("%d",&student[i].score[0]);     
        scanf("%d",&student[i].score[1]);
        scanf("%d",&student[i].score[2]);    
    }
    print(student,5); //调用函数
    return 0;
}
//输入1 grh 89 56 23 2 lop 78 45 12 3 asc 79 46 13 4 rfdg 84 51 20 5 fdr 95 62 30

  • 写回答

1条回答 默认 最新

  • micthis 2023-12-23 16:29
    关注

    name要定义成数组:

    struct grade                           
    {                                     
        int num;
        char name[32];
        int score[3];
    };
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 12月23日
  • 已采纳回答 12月23日
  • 创建了问题 12月23日

悬赏问题

  • ¥100 求懂行的大ge给小di解答下!
  • ¥15 pcl运行在qt msvc2019环境运行效率低于visual studio 2019
  • ¥15 MAUI,Zxing扫码,华为手机没反应。可提高悬赏
  • ¥15 python运行报错 ModuleNotFoundError: No module named 'torch'
  • ¥100 华为手机私有App后台保活
  • ¥15 sqlserver中加密的密码字段查询问题
  • ¥20 有谁能看看我coe文件到底哪儿有问题吗?
  • ¥20 我的这个coe文件到底哪儿出问题了
  • ¥15 matlab使用自定义函数时一直报错输入参数过多
  • ¥15 设计一个温度闭环控制系统