lex program to count the number of words

 

 

%{
#include<stdio.h>
#include<string.h>
int i=0;
%}
%%
([a-z]|[A-Z][0-9])*    {i++;}
“\n” {printf(“%d\n”,i);i=0;}
%%
main()
{
yylex();
return 0;
}
int yywrap()
{
}

Sample output

pls check the output
4

Leave a Reply

Your email address will not be published. Required fields are marked *