本地函数定义是非法的该怎么解决,链表,结构体。

新手小白 发布于 2015/03/26 23:08
阅读 1K+
收藏 0
#include<stdio.h>
#include<malloc.h>
#include<string.h>
#include<stdlib.h>
#include<conio.h>
int num = 0; void enter();
void mainmenu();
void init();
void input();
void save();
void add();
void del();
void alter();
void search();
void save();
struct pations{
char name[100];
char age[10];
char   sex[10];
char   suffer[100];
char   home[100];
char   state[100];
char   cure[100];
int date;
int date1;
struct pations *next;
}pa[500];
struct pations *head;
void mainmenu(){
int choice;
printf("病患管理系统\n");
printf("1添加新病患\n");
printf("2保存信息\n");
printf("3删除信息\n");
printf("4改变信息\n");
printf("5查找信息\n");
printf("6退出系统!\n");
scanf_s("%d", &choice);
switch (choice){
case 1: add();
case 2: save();
case 3: del();
case 4: alter();
case 5:  search();
case 6: exit(0);
}
}
void init(){
head = (pations*)malloc(sizeof(pations));
}
void input(){
int num = 0;
printf("****************************");
printf("请输入患者信息!");
printf("请输入患者的姓名!\n");
scanf_s("%s", &pa[num].name);
printf("请输入患者的年龄!");
scanf_s("%s", &pa[num].age);
printf("请输入患者的性别!");
scanf_s("%s", &pa[num].sex);
printf("请输入患者的患病!");
scanf_s("%s", &pa[num].home);
printf("请输入患者的住址!");
scanf_s("%s", &pa[num].state);
printf("请输入患者的医疗配方!");
scanf_s("%s", &pa[num].cure);
printf("是否继续添加?y/n");
if (_getch() == 'y')
{
enter();
}
return;
}
void save(){
FILE *stream;


errno_t err;
err = fopen_s(&stream, "pations", "a");
if (err == 0)
{
printf("文件'pations'已经打开!\n");
}
else
{
printf("无法打开 'pations'文件! \n");
}int numclosed = _fcloseall();
printf("文件已经被关闭!: %u\n", numclosed);
}
void del(){
int i = 0;
char mingzi[100];
struct pations *p;
head = (pations*)malloc(sizeof(pations));
p = head->next;
scanf_s("%s", &mingzi);
for (i; num >= i; i++)
{
head = head->next;
if (strcmp(mingzi, pa->name) == NULL)
{
p->next = head->next;
free(p);
printf("该病人已经被删除!");
}
printf("是否要继续删除?'y'or'n'\n");
if (_getch() == 'y')
{
void del();
}
return;
}
void search(){
int i;
for (i = 0; num >= i; i++)
{
head = head.next;
if (strcmp(mingzi, pa->name) == NULL)
{
p->next = head->next;
printf("%s病人已经被被找到!", mingzi);
}
else
{
printf("无法找到该病人!\n");
printf("按任意键返回主菜单!")
_getch();
}
}
}
int main(){
void init();
while (1);
void mainmenu();
}

代码还未完成,错误很多,勿喷,我只是大一新生。

错误代码:

错误 3 error C1075: 与左侧的 大括号“{”(位于“c:\users\lenovo-pc\documents\visual studio 2013\projects\consoleapplication59\consoleapplication59\源.cpp(89)”)匹配之前遇到文件结束 c:\users\lenovo-pc\documents\visual studio 2013\projects\consoleapplication59\consoleapplication59\源.cpp 140 1 ConsoleApplication59
错误 2 error C2601: “main”: 本地函数定义是非法的 c:\users\lenovo-pc\documents\visual studio 2013\projects\consoleapplication59\consoleapplication59\源.cpp 130 1 ConsoleApplication59
错误 1 error C2601: “search”: 本地函数定义是非法的 c:\users\lenovo-pc\documents\visual studio 2013\projects\consoleapplication59\consoleapplication59\源.cpp 112 1 ConsoleApplication59
4 IntelliSense:  应输入“;” c:\Users\lenovo-pc\Documents\Visual Studio 2013\Projects\ConsoleApplication59\ConsoleApplication59\源.cpp 112 15 ConsoleApplication59










加载中
返回顶部
顶部