Skip to main content

No of comments lines in the c file and eliminate them and save into other file



%{
#include<stdio.h>
int count=0;
%}

%%

"/*"[^\n]+"*/" {count++;fprintf(yyout,"");}

"//".* { count++; fprintf(yyout,"");}

%%

int main()
{
yyin=fopen("open.c","r");
yyout=fopen("new.c","w");
yylex();
printf("Number of Comments=%d\n",count);
        return 0;
}



How to run this file

1. run lex file  using command "flex filename.l "
2.  it generate the  c file which can be execute by command "cc  lex.yy.c -ll"
3. it will generate the executable file "./a.out "


Comments

  1. Lucky Club: The Definitive Guide to the Best Betting Sites & Sites
    Betting luckyclub sites for the whole of Europe. A guide to the best betting sites and websites to make money. The betting odds at these sites

    ReplyDelete

Post a Comment