lex program to display line nos with string hello
%{ #include #include int ln=1; %} %% “\n” {} .*hello.* {fprintf(yyout,”\n%d:%s”,ln++,yytext);} .* {ln++;} %% main() { yyin=fopen(“try1.txt”,”r”); yyout=fopen(“try2.txt”,”w”); yylex(); return 0; } int yywrap() { } Sample output try1.txt hai hello world test file language processor hello try2.txt 2:hello world 5:hello