lex program to find the size of a word

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

Sample output

test line processed
4 4 9

 

Digiprove sealCopyright secured by Digiprove © 2018-2020 Humble Chirammal