I am having trouble in using flex.
I wrote a C file happy.c as
int num_lines = 0, num_chars = 0;
%%
\n ++num_lines; ++num_chars;
. ++num_chars;
%%
main()
{
yylex();
printf( "# of lines = %d, # of chars = %d\n",
num_lines, num_chars );
}
Then I gave the command flex happy.c which produced lex.yy
Then I gave the command gcc lex.yy.c -lfl which generated a exe file.
But I don’t know how to use this exe file. For ex : When I gave the command
./a test (here test is a simple txt file)
It produced nothing. I mean program seems to hang.
Please tell me how to use the exe file.
Try this instead:
and then:
where
testcontained: