#+include+<+stdio+.+h+> +union+student+ +int+num+; +char+name+[20]; +int+age+; }; +int+main+(){ +uni
时间: 2023-12-29 11:04:18 浏览: 111
#include<stdio.h>
```c
#include <stdio.h>
union student {
int num;
char name[20];
int age;
};
int main() {
union student stu;
stu.num = 123;
printf("num: %d\n", stu.num);
strcpy(stu.name, "John");
printf("name: %s\n", stu.name);
stu.age = 20;
printf("age: %d\n", stu.age);
return 0;
}
```
输出结果:
```
num: 123
name: John
age: 20
```
阅读全文