Friday, April 12, 2019

lex program for display content of text file on output screen with a word “Hello” is replaced by “Hi”.


%{
  #include<stdio.h>
  int count=0;
%}
%%
[hH][Ee][Ll][Ll][oO] printf("HI");
%%
int main()
{
  FILE *fp;
  fp=fopen("5.txt","r");
  if(fp==NULL)
  {
       printf("Error");
  return 0;
  }
  yyin=fp;
  yylex();
}

ScreenShot:


No comments:

Post a Comment