求一C高手帮解答一题

来源:百度知道 编辑:UC知道 时间:2024/06/03 07:49:31
题目为:用栈来做一个密码验证程序,密码验证只有三次机会。
网上有人给出以下程序语言,可查出有两处错误。劳烦高手帮该一下。谢谢。
以下为那个程序得网址,我们也要做这个题目。真是麻烦
http://tieba.baidu.com/f?kz=161214014

给,已经都改好了:
#include<stdio.h>
#include<string.h>
#include<conio.h>
#include<stdlib.h>
#include<windows.h>

#define STACK_INIT_SIZE 16
#define OK 1
#define TRUE 1
#define FALSE 0
#define ERROR 0
char PASSWORD[16]="12345678"; /*密码,全局变量*/
typedef char SElemType;
typedef struct STACK /*定义栈类型*/
{
SElemType *base; //定义栈底指针
SElemType *top; //定义栈顶指针
int stacksize; //定义栈的Size
int length; //定义栈长,也就是栈中的成员个数
}SqStack,*Stack;
typedef int Status;
void InitStack(Stack *S) /*初始化栈*/
{
*S=(SqStack *)malloc(sizeof(SqStack)); //申请栈空间
(*S)->base=(SElemType *)malloc(STACK_INIT_SIZE*sizeof(SElemType)); //申请栈底成员空间,也就是栈的第一个压栈成员
if(!(*S)->base)exit(-1); //容错处理,malloc失败,则退出
(*S)->top=(*S)->base; //先将栈顶指针指向栈底(当前没有成员压栈)
(*S)->stacksize=STACK_INIT_SIZE;
(*S)->length=0;
}
Status Des