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:
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.