Home > Back-end >  Why did the inside SIGQUIT will always display is not defined
Why did the inside SIGQUIT will always display is not defined

Time:09-20

# include "stack. H"
# include "queue. H"
#include
#include
#include
#include
# include "editor. CPP
"
Int exit_flag;

STD: : string * info_fetch ();
Int exit_gracefully ();

Int exit_gracefully ()
{
If (the history!=NULL)
{
Delete the history.
}
If (TMP!=NULL)
{
Delete the TMP;
}
return 0;
}

STD: : string * info_fetch ()
{
Char buffer_ [128].
The fgets (buffer_, 128, stdin);
for (int i=0; i <128; I++)
{
If (buffer_ [I]=='\ n')
{
Buffer_ [I]='\ 0';
}
}
If (buffer_ [0]=='\ 0')
{
Return NULL;
}
STD: : string * buffer=new STD: : string (buffer_);
The return buffer;
}

Void int_handle (int sig)
{
If (sig==SIGINT)
{
Undo ();
History - & gt; print();
printf("\n");
}
}

Void quit_handle (int sig)
{
If (sig==SIGQUIT)
{
If (exit_flag==0) {
Printf ("==========memory is cleared=========\ n ");
Exit_gracefully ();
Printf ("====then a Ctrl + \ \ can exit the====\ n ");
Exit_flag=1;
}
The else {
Printf ("==========to exit gracefully=========\ n ");
exit(0);
}
}
}

Int main (int arg c, char * argv [])
{
If (arg c!=1) {
Printf (" the Usage:/main \ n ");
exit(1);
}
Signal (SIGINT, int_handle);
Signal (SIGQUIT, quit_handle);
Printf (" \ n===========================please according to the prompt \ n \ n press Ctrl + c to return to the previous step, press Ctrl + \ \ \ n to exit \ n===========================\ n ");
Printf (" please enter an instruction, or input resume redo \ n ");
While (true)
{
STD: : string * buffer=info_fetch ();
If (buffer==NULL)
{
continue;
}
If (buffer - & gt; Compare (" resume ")==0)
{
Printf ("==========on redo step=========\ n ");
Resume ();
continue;
}
If (history==NULL)
{
The history=new Stack (a);
}
Printf ("=========receive instructions========\ n ");
History - & gt; Push (buffer);
}
return 0;
}

CodePudding user response:

Lack of dependence: # include & lt; Csignal>
  • Related