lex program to find the size of a word

 

 

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

Sample output

test line processed
4 4 9

 

Leave a Reply

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