C语言编程、、
想编个管理系统的程序、、才弄了一点点、、就出错了、、杯具啊、、大家帮帮忙啊、、谢谢了
#include<stdio.h>
#include<conio.h>
#include<malloc.h>
#include<stdlib.h>
typedef struct students
{
char name[15];
struct studentMessage
{
char sex;
int age;
float height;
float weight;
}Mess;
struct students *ahead;
struct students *next;
}STU;
void CreatMessage(STU *head);
void FindMessage(void);
void PrintMessage(void);
void AddMessage(void);
void DeleteMessage(void);
void main()
{
STU *head;
int selectionNumber;
char choiceForExit,choice;
printf("************************************\n");
printf("* *\n");
printf("* Students Administration System *\n");
printf("* *\n");
printf("************************************\n\n");
printf("Look this selection!\nWould you like to make a selection?\n");
printf("Please enter your choice:\n\n");
while(1)
{
clrscr();
printf("\t\t************************************\n");
printf("\t\t* *\n");
printf("\t\t* Students Administration System *\n");
printf("\t\t* *\n");
printf("\t\t************************************\n\n");
printf("\t\tLook this selection!\n\t\tWould you like to make a selection?\n");
printf("\t\tPlease enter your choice:\n\n");
printf("\t\t\t1 : Creat Message\n");
printf("\t\t\t2 : Find Message\n");
printf("\t\t\t3 : Print Message\n");
printf("\t\t\t4 : Add Message\n");
printf("\t\t\t5 : Delete Message\n");
printf("\t\t\t6 : Exit\n\n\t\tYour choice: ");
scanf("%d",&selectionNumber);
switch(selectionNumber)
{
case 1:
printf("\t\tDo you want to Creat one?(Y\\N)\n\t\t");
choice=getche();
if(tolower(choice)=='n')
head=NULL;
else
CreatMessage(head); /*创建学生信息*/
break;
case 2:
FindMessage(); break;
case 3:
PrintMessage(); break;
case 4:
AddMessage(); break;
case 5:
DeleteMessage();break;
case 6:
printf("\n\n\t\tDo you really want to exit? (N\\Y)\n\t\t");
choiceForExit=getche();
if(tolower(choiceForExit)=='y')
exit(0);
else
break;
default :
break;
}
}
getch();
}
/*创建学生信息*/
void CreatMessage(STU *head)
{
STU *creat;
char choice;
clrscr();
creat=(STU *)malloc(sizeof(STU)); /*分配空间*/
head=creat;
if(!creat) /*判断是否为NULL*/
{
printf("\t\tMemory limit,can not creat!\n");
exit(0);
}
else /*输入信息*/
{
printf("\n\n\t\tPlease enter Name: ");
scanf("%s",creat->name);
printf("\n\t\tB or G? : ");/*运行到这里自动关闭了为什么啊?*/
creat->Mess.sex=getchar();
printf("\n\t\tWhat's height? : \n");
scanf("%f",&creat->Mess.height);
printf("\n\t\tAnd Weight? : ");
scanf("%f",&creat->Mess.weight);
while(1)
{
clrscr();
printf("\t\tWould you like to creat more?(Y\\N)\n");
scanf("%c",&choice);
if(tolower(choice)=='n')
{
creat->next=NULL;
break;
}
else
{
creat->next=(STU *)malloc(sizeof(STU));
if(!creat->next==NULL)
{
printf("\t\tMerry out!\n");
break;
}
else
{
creat->next->ahead=creat;
creat=creat->next;
printf("\n\t\tPlease enter Name: ");
scanf("%s",creat->name);
printf("\n\t\tB or G? : ");
scanf("%d",&creat->Mess.sex);
printf("\n\t\tWhat's height? : ");
scanf("%f",&creat->Mess.height);
printf("\n\t\tWeight : ");
scanf("%f",&creat->Mess.weight);
printf("\n\t\t");
}
creat=NULL;
}
}
}
}
void FindMessage(void)
{
}
void PrintMessage(void)
{
}
void AddMessage(void)
{
}
void DeleteMessage(void)
{
}