identify a sentence and return the length of each word.
%{
int a=0;
int a2;
%}
%%
" " {a++;}
[a-zA-Z]+ {printf("word: %s \t\t letters in the word: %d\n",yytext,yyleng);}
%%
main()
{
yylex();
a=a+1;
printf("Sentence lenght: %d",a);
}
int a=0;
int a2;
%}
%%
" " {a++;}
[a-zA-Z]+ {printf("word: %s \t\t letters in the word: %d\n",yytext,yyleng);}
%%
main()
{
yylex();
a=a+1;
printf("Sentence lenght: %d",a);
}
Comments
Post a Comment