此程序编译后啥也没输出 空白一片咋回事哈 求大佬指点下哪里出了问题呢
#include<stdio.h>#include<stdlib.h>
#include<string.h>
typedef struct Teacher
{
char name[64];
char *alisname;
char **stuname;
int age;
}Teacher;
int printTeacher(Teacher *Array1,int num)
{
int i=0;
if(Array1=NULL)
{
return -1;
}
for(i=0; i<num; i++)
{
printf("%d",Array1[i].age);
}
return 0;
}
int sortTeacher(Teacher *Array2,int num)
{
int i,j;
Teacher tmp;
if(Array2==NULL)
{
return -2;
}
for(i=0; i<num; i++)
{
for(j=i+1; j<num; j++)
{
if(Array2[i].age > Array2[i].age)
{
tmp = Array2[i];
Array2[i] = Array2[j];
Array2[j] = tmp;
}
}
}
return 0;
}
int CreateTeacher(Teacher **Array3,int num)
{
int i=0,j=0;
Teacher *tmp=NULL;
if(Array3==NULL)
{
return -3;
}
tmp=(Teacher *)malloc(sizeof(Teacher)*num);
if(tmp==NULL)
{
printf("func CreateTeacher(if(tmp==NULL))err\n");
return NULL;
}
memset(tmp,0,sizeof(Teacher)*num);
for(i=0;i<num;i++)
{
char **p=NULL;
tmp[i].alisname=(char *)malloc(60);
p=(char **)malloc(sizeof(char *)*num);
if(p=NULL)
{
printf("func CreateTeacher( p=(char **)malloc(sizeof(char *)*num))err\n");
return NULL;
}
memset(p,0,sizeof(char *)*num);
for(j=0; j<num; j++)
{
p[j]=(char *)malloc(60);
}
tmp[i].stuname=p;
}
*Array3=tmp;
return 0;
}
int FreeTeacher(Teacher *Array4,int num)
{
int i=0,j=0;
Teacher *Linshi=NULL;
Linshi=Array4;
if(Array4==NULL)
{
return -4;
}
for(i=0;i<num;i++)
{
if(Linshi[i].alisname!=NULL)
{
free(Linshi[i].alisname);
}
if(Linshi[i].stuname!=NULL)
{
char **MyNeiCun=Linshi[i].stuname;
for(j=0; j<num; j++)
{
if(MyNeiCun[j]!=NULL)
{
free(MyNeiCun[j]);
}
}
free(MyNeiCun);
Linshi[i].stuname=NULL;
}
}
free(Linshi);
Array4=NULL;
return 0;
}
int main(void)
{
int ret=0,i=0,j=0,num=3;
Teacher *pArray=NULL;
ret=CreateTeacher(&pArray,num);
if(ret!=0)
{
printf("func ret=CreateTeacher(&pArray,num)err:%d",ret);
return ret;
}
for(i=0; i<num; i++)
{
printf("\n 请输入老师的年龄:");
scanf("%d",&(pArray[i].age));
printf("\n 请输入老师的名字:");
scanf("%s",pArray[i].name);
printf("\n 请输入老师的别名:");
scanf("%s" ,pArray[i].alisname);
for(j=0; j<num; j++)
{
printf("请输入第%d个学生的名字:",j+1);
scanf("%d",pArray[i].stuname[j]);
}
}
printf("排序之前\n");
printTeacher(pArray,num);
sortTeacher(pArray,num);
printf("排序之后\n");
printTeacher(pArray,num);
printf(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n");
printf("释放内存中>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n");
FreeTeacher(pArray,num);
printf("释放内存完毕>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n");
system("pause");
return 0;
}