结构体的输入输出,那里错了!!

来源:百度知道 编辑:UC知道 时间:2024/07/04 13:42:08
#include <stdio.h>
#include <string.h>
struct
{
int num;
char name[10];
char sex;
char job;
union{
long class;
char postion[10];
}category;
}person[2];
void main()
{
int i;
clrscr();
for (i=0;i<2;i++)
{
printf("input the %d person's message:\n",i+1);
scanf("%d%s",&person[i].num,&person[i].name);
getchar();
scanf("%c%c",&person[i].sex,&person[i].job);
getchar();
if(toupper(person[i].job)=='s')
{
printf("\ninput class:\n");
scanf("%ld",&person[i].category.class);
}
else if(toupper(person[i].job)=='t')
{

printf("\ninput postion:\n");
scanf("%c",&person[i].category.class);
}
else
printf("i

你的程序错误也太多了吧,35个错误!你是不是刚在学编程?你用的是不是 VC6.0?
第十行:class在VC中是关键字,不可用做变量名
改一下,就减为两个错误了
第十七行:clrscr未定义,那是个什么东西?函数吗?
第二十五行:toupper是你编的函数吗?对函数的定义应该在程序中显示出来
你先把这几个错误改一改,可能会好一些.
最后,提一点小小的建议,你写程序的风格不太好,让人很难看!