Lexical analysis: the code does not execute after yylex()

question

When using lex for lexical analysis, it is found that the code after the yylex() function is not executed, the code is as follows, and "hello" is not output

int main(int argc,char *argv[])
{
    
    
   printf("请输入您要进行词法分析的程序段\n");  
   yylex();
   printf("hello\n");
return 0;
}

Similar to this:
insert image description here

Solution

The reason for not executing is that you have not exited yylex() yet, and you are still waiting for input.
Operation method: ctrl+z and press Enter.
The result is as shown in the figure, and the problem is solved.
insert image description here

Guess you like

Origin blog.csdn.net/qq_43666766/article/details/115189327