Sunday, 16 June 2019

Write a LEX program that reads input from input file and write backs same content by replacing printf by write and scanf by read keyword in output file.


            

               Code :

%{
#include<stdio.h>
#include<string.h>
%}
%%
"printf" {fprintf(yyout,"write",yytext);}
"scanf" {fprintf(yyout,"read",yytext);}
. ; {fprintf(yyout,"%s",yytext);} 
%%
main()
{
yyin=fopen("input.txt","r");
yyout=fopen("output.txt","w");
yylex();
}
int yywrap()
{
return(1);
}

No comments:

Post a Comment

It's time To increase blogging capability. To have a chance to contribute in digital world. Any Interested People who want to make t...