%{
#include<stdio.h>
int count=0;
int letter=0;
int lcount=0;
%}
%%
[a-zA-Z0-9] {letter++;}
" " {count++;}
"\n" {lcount++;
count++; printf("\n Total words are: %d\n Total Letters are: %d\n Total
Lines are: %d\n",count,letter,lcount); lcount=0; count=0; letter=0;}
%%
int yywrap()
{
return 1;
}
int main()
{
yyin=fopen("test.txt","r");
yylex();
return 0;
}
ScreenShot:
No comments:
Post a Comment