请教一下,编译报错error C2440: '=' : cannot convert from 'struct Table *' to 'struct main
#include<stdio.h>#include<stdlib.h>
struct EngineerDuty
{
char Duty[50];
char Project[50];
int ProjectNum;
};
struct Table
{
char name[32];
int age;
char job[32];
union DifferPart
{
int ClassCode;
char Department[20];
struct EngineerDuty EngDuty;
}TeacherStudentEngineer;
};
void InputInfo(struct Table *InputTable,unsigned n)
{
unsigned int i=0;
// 3sstruct Table *CopyInput=InputTable;
printf("开始处理函数InputInfo()\n");
for(;i<n;i++)
{
printf("请输入No.%d个人的姓名 年龄和工作:\n",i+1);
scanf("%s %d %s",InputTable->name,
&InputTable->age,
InputTable->job);
if('S'==InputTable->job[0]||'s'==InputTable->job[0])
{
printf("请输入学生的学号:\n");
scanf("%d",&InputTable->TeacherStudentEngineer.ClassCode);
}
else
if('T'==InputTable->job[0]||'t'==InputTable->job[0])
{
printf("请输入老师的系别:\n");
scanf("%s",InputTable->TeacherStudentEngineer.Department);
}
if('E'==InputTable->job[0]||'e'==InputTable->job[0])
{
printf("请输入工程师的职责:\n");
scanf("%s %s %d",InputTable->TeacherStudentEngineer.EngDuty.Duty,
InputTable->TeacherStudentEngineer.EngDuty.Project,
InputTable->TeacherStudentEngineer.EngDuty.ProjectNum);
}
InputTable++;
}
}
void OutputInfo(struct Table *OutputTable,unsigned n)
{
unsigned int i=0;
printf("开始处理函数:OutputInfo()\n");
for(;i<n;i++)
{
if('S'==OutputTable->job[0]||'s'==OutputTable->job[0])
{
printf("输出学生的信息:\n");
printf(" name age job classCode\n");
printf(" %s %d %s %d\n",OutputTable->name,
OutputTable->age,
OutputTable->job,
OutputTable->TeacherStudentEngineer.ClassCode);
}
else
if('T'==OutputTable->job[0]||'t'==OutputTable->job[0])
{
printf("输出老师的信息:\n");
printf(" name age job department\n");
printf(" %s %d %s %d\n",OutputTable->name,
OutputTable->age,
OutputTable->job,
OutputTable->TeacherStudentEngineer.Department);
}
if('E'==OutputTable->job[0]||'e'==OutputTable->job[0])
{
printf("输出学生的信息:\n");
printf(" name age job duty project projectNum\n");
printf(" %s %d %s %s %s %d\n",OutputTable->name,
OutputTable->age,
OutputTable->job,
OutputTable->TeacherStudentEngineer.EngDuty.Duty,
OutputTable->TeacherStudentEngineer.EngDuty.Project,
OutputTable->TeacherStudentEngineer.EngDuty.ProjectNum);
}
OutputTable++;
}
}
void main()
{
int size=0;
struct *TableOfTeaAndStuAndEng;
struct *CopyTableOfTeaAndStuAndEng;
size=sizeof(struct Table);
printf("结构体Table的大小为:%d\n",size);
TableOfTeaAndStuAndEng=(struct Table *)malloc(3*size);
InputInfo(TableOfTeaAndStuAndEng,3);
OutputInfo(TableOfTeaAndStuAndEng,3);
}