user-0 提问: C语言急求 停车场管理

回复:
user: user-1
content: 建议楼主先把基础打好，一步一步来

user: user-0
content: 用C++6.0软件很多错误.......

user: user-0
content: 好多错误哦，怎么办？

user: user-2
content: main函数里面改了一下你看看

user: user-2
content: #include <stdio.h> #include <stdlib.h> #include <malloc.h> #include <conio.h> #include <string.h> #define  MAXLEN1  12   //设置停车场最大长度 #define  MAXLEN2  3    //设置便道最大长度  typedef struct STOP_CAR//定义栈的结构体(停车场和临时停车场) { 	char   platename[8];    //车牌号码 	int    arr_time;        //停车时间 	int    lea_time;        //离开时间 	int    stoptime;        //停车时长 	int    flag;            //车辆状态信息 	float  charge;          //费用 	struct STOP_CAR *next;  //指针域 }S_car,*pS_car;  typedef struct PAVEMENT_CAR//定义队列的结构体(便道) { 	char    platename[8];        //车牌号码 	struct  PAVEMENT_CAR *next;      //指针域 }Q_car,*pQ_car;  struct PAVEMENT_LINK//设立队列指针节点(便道) { 	Q_car  *front;              //队首指针 	Q_car  *rear;               //队尾指针 }; typedef struct PAVEMENT_LINK Q_link;  Q_link lineset(Q_link link,int len)//设立空便道,形参类型是队头指针(地址)和长度(车位数目) { 	int i; 	for(i=1;i<=len;i++) 	{ 		if(link.front == NULL) 		{ 			link.front = (Q_car *)malloc(sizeof(Q_car)); 			if(link.front == NULL)//安全性 			{ 				printf("No enough memory to alloc!\n"); 				getch(); 				exit(0); 			} 			link.front->next = NULL; 			link.rear = link.front; 		} 		else 		{ 			link.rear->next = (Q_car *)malloc(sizeof(Q_car)); 			if(link.rear->next == NULL) 			{ 				printf("No enough memory to alloc!\n"); 				getch(); 				exit(0); 			} 			link.rear = link.rear->next; 			link.rear->next = NULL; 		} 	} 	return link; }  S_car * parkingset(S_car * top,int len)//设立空停车场,形参类型是栈顶指针(地址)和长度(车位数目) { 	int i; 	S_car *s = NULL; 	S_car *sr ; 	sr = top; 	for(i=1;i<=len;i++) 	{ 		s=(S_car *)malloc(sizeof(S_car));//为新节点申请动态内存空间 		if(s == NULL)//申请空间失败后,退出程序 		{ 			printf("No enough memory to alloc!\n"); 			getch(); 			exit(0); 		} 		if(top == NULL)//若栈顶为空,则将新建节点的指针变量地址传给栈顶 		{ 			top = s; 		} 		else          //若栈顶不为空,则将下一个新建变量的地址传给上一个刚连接的节点 		{ 			sr->next = s; 			sr = sr->next; 			sr->next=NULL; 		} 		sr=s; 	} 	return top;   //返回栈的头结点指针(地址) }  Q_link Inline(Q_link link,int *num,int len)//单辆车车入便道 { 	int i; 	Q_car * r = link.front; 	if(*num == 1)	//判断便道是否有车 		printf("便道没有车在等候。\n"); 	else 		printf("便道有车在等候。\n"); 	if(*num > len) 		printf("便道已满车,请等待车辆进入后再来。\n"); 	for(i=0;i<len;i++) 	{ 		if(*num-1 == i) 		{ 			printf("请输入车牌号码:"); 			scanf("%s", link.front->platename); 			printf("车牌号码为%s的车辆已在%d号便道位中等待。\n",link.front->platename,*num); 		} 	} 	(*num)++; 	return link; }  void Push_stack(Q_link link,S_car * top,int len1,int *num1,int *num2)//停车(入栈,具体是将队列里的节点的内容复制到栈的节点上,并记录入停车场的时间) { 	int i; 	int n = 1; 	char platename[8]; 	Q_car * start1 = link.front;//指向队头 	Q_car * trans = link.front;//便道向前移动一步 	S_car * start2 = top;//指向站头 	S_car * find = top;//该指针用于寻找元素  	if(strcmp(start1->platename,"")==0) 		printf("便道没有车,请让至少一辆车进入便道。\n"); 	else 	{ 		if(strcmp(start2->platename,"") == 0) 			printf("停车场已满,请等至少一辆车离开之后再进入。\n"); 		else 		{ 			for(i=1;i<=(*num2);i++) 				find = find->next; 			strcpy(find->platename,start1->platename); 			printf("车牌号码为%s的车辆已从1号便道车位转入%d号车位。\n",find->platename,*num2); 			(*num1)--; 			(*num2)++; 			find->flag = 1;//标记停车信息 			strcpy(link.front->platename,""); 			trans = start1; 		} 	} 	if(strcmp(trans->platename,"") == 0) 	{ 		for(i=1;i<=(*num1);i++) 		{ 			trans = trans->next; 			if(i==1) 			{ 				strcmp(platename,trans->platename); 				trans = start1; 				strcmp(start1->platename,platename); 				n++; 			} 			else 			{ 				strcmp(platename,trans->platename); 				trans = start1; 				for(i=1;i<(*num1);i++) 				{ 					trans = trans->next; 					if(i ==(*num1)-1) 						strcmp(trans->platename,platename); 				} 			} 			trans = start1; 		} 	} }  char * Pop_Stack(S_car * top1,S_car * top2,int *num3,int len1)//车离开 { 	int i; 	int j; 	int point; 	char platename[8]; 	S_car * start1 = top1; 	S_car * find1 = top1; 	S_car * start2 = top2; 	S_car * find2 = top2; 	do 	{ 		printf("请输入离开的停车场车位编号(1~%d):",len1); 		scanf("%d",&point); 		printf("Enput error!Please input again. \n"); 		system("cls"); 	} 	while(point<=1 || point>=len1); 	for(i=1;i<=point;i++) 	{ 		find1 = find1->next; 	} 	if(strcmp(find1->platename,"")==0) 	{ 		printf("该车位没有车辆,无法进行操作。\n"); 		find1 = start1; 	} 	else 	{ 		for(i=1;i<point;i++) 			find1 = find1->next; 		if(strcmp(find1->platename,"") == 0) 		{ 			find1 = find1->next;	 			strcpy(platename,find1->platename); 			printf("车牌号码为%s的车辆已从%d号停车位离开停车场。\n",platename,point); 			strcpy(find1->platename,""); 			find1 = start1; 		} 		else 		{ 			find1 = start1; 			for(i=1;;i++) 			{ 				if(strcmp(find1->platename,"") != 0) 				{ 					for(j=1;j<len1;j++) 					{ 						find2 = find2->next; 						if(j = (*num3)) 						{ 							strcpy(find2->platename,find1->platename); 							printf("车牌号码为%s的车辆已从%d号停车场车位转入%d号临时停车场车位。\n",find2->platename,point,(*num3)); 							(*num3)++; 						} 					} 				} 			} 		} 	} 	printf("车牌号码为%s的车辆已从%d停车位离开停车场。\n",platename,point); 	return platename; }  int Menu(int select)//选择菜单显示 { 	printf("本程序功能如下:\n"); 	printf("1、单个汽车进入便道(请输入1)\n"); 	printf("2、单个汽车进入停车场(请输入2)\n"); 	printf("3、单个汽车离开停车场(请输入3)\n"); 	printf("4、退出程序(请输入0)\n"); 	printf("请输入数字进行功能选择:(输入数字后,按回车结束)\n"); 	scanf("%d",&select); 	return select; }   int main()//主函数 { 	int len,len1;//len是便道车位数,len1是停车场位数      	printf("请规定便道车位位数(最大不超过%d):",MAXLEN2); 	scanf("%d",&len); 	printf("请规定停车场车位位数(最大不超过%d):",MAXLEN1); 	scanf("%d",&len1); 	int select,select0; 	select=0;///////////////////////////////////赋值       	int p = 1; 	int * num1 = &p;	//录入当前便道车辆数 	int q = len1; 	int * num2 = &q;	//录入当前停车场停车位号 	int r = len1; 	int * num3 = &r;	//录入当前临时停车场停车位位号 	char * leave = {NULL};  	Q_link link; 	S_car * top2 = NULL; 	S_car * top1 = NULL;//初始化停车场栈顶 	link.front = NULL;//初始化队首指针 	link.rear = NULL; //初始化队尾指针  	  	//建立便道部分 	link = lineset(link,len);     //将队列指针的地址赋值给头指针 	printf("便道初始化完成！\n");  	//停车场部分 	top1 = parkingset(top1,len1); 	printf("停车场初始化完成！\n");  	//临时停车场部分 	top2 = parkingset(top2,len1);  	do 	{ kaiguan: 		select = Menu(select); 		switch(select) 		{ 		case 1 : 			system("cls"); 			Inline(link,num1,len); 			break; 		case 2 : 			system("cls"); 			Push_stack(link,top1,len1,num1,num2); 			break; 		case 3 : 			system("cls"); 			leave = Pop_Stack(top1,top2,num3,len1); 			break; 		case 0 : 			system("cls"); 			printf("Thank you for your using!\n"); 			getch(); 			exit(0); 		default: 			printf("Input error!Please input again.\n"); 		} 		printf("Do you want to continue?\n");//询问是否继续操作 		printf("If yes,input 1.\n"); 		printf("Else,input 0.\n"); 		scanf("%d",&select0); 		system("cls"); 		if(select0 == 1) 			goto kaiguan; 	} 	while(select0 != 0 ); 	return 0; }

user: user-2
content: 好多变量都没赋值你就开始用了