联合的不确定输出

问题描述

我有以下C程序

#include <stdio.h>

union student{
char name[20];
int id;
float percentage;
}student1;

int main()
{
    printf(" Enter name,id and then percentage \n");
    scanf("%s",student1.name);
    scanf("%d",&student1.id);
    scanf("%f",&student1.percentage);

    printf("Details of student are:");
    printf("Name %s,ID: %d,Percentage: %f",student1.name,student1.id,student1.percentage);
}

输出如下:

Enter name,id and then percentage  
Nik  
90  
7.9  
Details of student are:Name ═╠ⁿ@,ID: 1090309325,Percentage: 7.900000  
Process returned 0 (0x0)   execution time : 7.665 s  
Press any key to continue.  

问题是为什么这对工会不起作用。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)