This is my line editing program.
# Include <stdio. h>
# Include <stdlib. h>
# Define STACK_INIT_SIZE 100
# Define MAXSIZE 50
# Define INCREMENT 10
# Define OVERFLOW-2
# Define ERROR-1
# Define OK 0
Typedef struct
{
Int * base;
Int * top;
Int StackSize;
} SqStack, * PStack;
Void InitStack (PStack S );
Void DestroyStack (PStack S );
Void ClearStack (PStack S );
Int GetTop (PStack S, int * e );
Void Push (PStack S, int e );
Int Pop (PStack S );
Void InitStack (PStack S)
{
If (! (S-> base = (int *) malloc (STACK_INIT_SIZE * sizeof (int ))))
Exit (OVERFLOW );
S-> top = S-> base;
S-> StackSize = STACK_INIT_SIZE;
Return;
}
Void DestroyStack (PStack S)
{
Free (S-> base );
S-> top = S-> base;
Return;
}
Void ClearStack (PStack S)
{
S-> top = S-> base;
Return;
}
Int GetTop (PStack S, int * e)
{
If (S-> top = S-> base)
Return ERROR;
* E = * (S-> top-1 );
Return OK;
}
Void Push (PStack S, int e)
{
If (S-> top-S-> base> = S-> StackSize)
{
S-> base = (int *) realloc (S-> base, (STACK_INIT_SIZE + INCREMENT) * sizeof (int ));
If (! S-> base)
Exit (OVERFLOW );
S-> top = S-> base + S-> StackSize;
S-> StackSize = S-> StackSize + INCREMENT;
}
* S-> top ++ = e;
Return;
}
Int Pop (PStack S)
{
If (S-> top-S-> base = 0)
Return ERROR;
S-> top --;
Return OK;
}
Int main ()
{
SqStack S;
Char ch;
FILE * fp;
Char Array [MAXSIZE];
Int * p;
Int I;
InitStack (& S );
Printf ("please enter the context: n ");
Ch = getchar ();
While (ch! = '! ')
{
While (ch! = '! '& Ch! = 'N ')
{<