求简单行编译器

来源:百度知道 编辑:UC知道 时间:2024/07/04 07:58:32
简单的行编缉器
要求:
1)设置一个简单的行编缉器,每行以回车结束;
2)数据以文件形式存储;
3)编辑器具有查找、替换、修改数据的功能。

在C++ 6.0上可运行
代码 发到 327584233@qq.com
快点哦 我今天就给分 急

#include <stdlib.h>
#include <stdio.h>
#include <malloc.h>
#include <string.h>
#include <conio.h>
#define STACK_INIT_SIZE 100
#define STACKINCREMENT 10

struct SqStack
{
char *base;
char *top;
int stacksize;
};

void InitStack(SqStack &S)
{
S.base=(char*)malloc(STACK_INIT_SIZE *sizeof(char));
if (!S.base)
exit(1);
S.top=S.base;
S.stacksize=STACK_INIT_SIZE;
}

void push(SqStack &S,char e)
{
if(S.top-S.base>=S.stacksize)
{
S.base=(char*)realloc(S.base,(S.stacksize+STACKINCREMENT)*sizeof(char));
if (!S.base)
exit(1);
S.top=S.base+S.stacksize;
S.stacksize+=STACKINCREMENT;
}
*S.top++=e;
}
char pop(SqStack &S,char &e)
{
if (S.top==S.base)
return false;
e=*--S.top;
return e;
}

void ClearStack