Home > Software engineering >  A simple line editor error correction, don't know how to solve
A simple line editor error correction, don't know how to solve

Time:10-17

#include
#include
#include
#include
#include
# define STACK_INIT_SIZE 100
# define STACKINCREMENT 10
Struct SqStack
{
Char * base;
Char * top;
Int stacksize;
};
Void InitStack (SqStack & amp; S)
{
S.b ase=(char *) malloc (STACK_INIT_SIZE * sizeof (char));
if (! S.b ase)
exit(1);
S.t op=S.b ase;
S.s tacksize=STACK_INIT_SIZE;
}
Void push (SqStack & amp; S, char e)
{
If (S.t op - S.b ase>=S.s tacksize)
{
S.b ase=(char *) realloc (S.b ase, (S.s tacksize + STACKINCREMENT) * sizeof (char));
if (! S.b ase)
exit(1);
S.t op=S.b ase + S.s tacksize;
S.s tacksize +=STACKINCREMENT;
}
* S.t op++=e;
}
Char pop (SqStack & amp; S, char & amp; E)
{
If (S.t op==S.b ase)
return false;
E=* - S.t op;
Return e;
}
Void ClearStack (SqStack & amp; S)
{
S.t op=S.b ase;
}
Void DestroyStack (SqStack & amp; S)
{
Free (S.b ase);
S.t op=S.b ase;
}
Bool StackEmpty (SqStack & amp; S)
{
If (S.t op==S.b ase)
return true;
return false;
}

Void main ()
{
Char ch, e;
SqStack S, D;
InitStack (S);
InitStack (D);
Ch=getchar ();
While (ch!=(EOF)
{
While (ch!=EOF& & Ch! )
='\ n'{
The switch (ch)
{
Case '#' : pop (S, e); break;
Case: '@' ClearStack (S); break;
Default: push (S, ch); break;
}
Ch=getchar ();
}
while (! StackEmpty (S))
{
E=pop (S, e);
Push (D, e);
}


-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- the Configuration: Cpp1 - Win32 Debug -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
The Compiling...
Cpp1. CPP
C: \ Users \ lenovo \ Desktop \ Cpp1 CPP (81) : fatal error C1004: unexpected end of file found
An error occurred when executing cl. Exe.

Cpp1. Exe - 1 error (s), and 0 warning (s)

CodePudding user response:

The front plus stdafx. H or sets do not use the precompiled header file attributes

CodePudding user response:

 # include & lt; Stdlib. H> 
#include
#include
#include
#include
# define STACK_INIT_SIZE 100
# define STACKINCREMENT 10
Struct SqStack
{
Char * base;
Char * top;
Int stacksize;
};
Void InitStack (SqStack & amp; S)
{
S.b ase=(char *) malloc (STACK_INIT_SIZE * sizeof (char));
if (! S.b ase)
exit(1);
S.t op=S.b ase;
S.s tacksize=STACK_INIT_SIZE;
}
Void push (SqStack & amp; S, char e)
{
If (S.t op - S.b ase>=S.s tacksize)
{
S.b ase=(char *) realloc (S.b ase, (S.s tacksize + STACKINCREMENT) * sizeof (char));
if (! S.b ase)
exit(1);
S.t op=S.b ase + S.s tacksize;
S.s tacksize +=STACKINCREMENT;
}
* S.t op++=e;
}
Char pop (SqStack & amp; S, char & amp; E)
{
If (S.t op==S.b ase)
return false;
E=* - S.t op;
Return e;
}
Void ClearStack (SqStack & amp; S)
{
S.t op=S.b ase;
}
Void DestroyStack (SqStack & amp; S)
{
Free (S.b ase);
S.t op=S.b ase;
}
Bool StackEmpty (SqStack & amp; S)
{
If (S.t op==S.b ase)
return true;
return false;
}

Void main ()
{
Char ch, e;
SqStack S, D;
InitStack (S);
InitStack (D);
Ch=getchar ();
While (ch!=(EOF)
{
While (ch!=EOF& & Ch! )
='\ n'{
The switch (ch)
{
Case '#' : pop (S, e); break;
Case: '@' ClearStack (S); break;
Default: push (S, ch); break;
}
Ch=getchar ();
}
while (! StackEmpty (S))
{
E=pop (S, e);
Push (D, e);
}
}
}
  • Related