Created
May 2, 2019 16:15
-
-
Save vnkdj5/10d24e3c9d6a2127c588e9edb5531ddf to your computer and use it in GitHub Desktop.
Word Count Program using Lex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vaibhav kumbhar | |
3434 | |
PICT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%{ | |
int nlines,nwords,nchars; | |
%} | |
%% | |
\n { | |
nchars++;nlines++; | |
} | |
[^ \n\t]+ {nwords++, nchars=nchars+yyleng;} | |
. {nchars++;} | |
%% | |
int yywrap(void) | |
{ | |
return 1; | |
} | |
int main(int argc, char*argv[]) | |
{ | |
yyin=fopen(argv[1],"r"); | |
yylex(); | |
printf("Lines = %d\nChars=%d\nWords=%d",nlines,nchars,nwords); | |
return 0; | |
} |
I'm not getting any output it's asking for data continuously
Did you try the compilation steps as given on below link:
httpss://www.way2techin.com/2019/05/lex-program-to-count-words-lines-and.html
See the screenshot. It should work. You must be doing something differently. As we all executed same programs in our college days🤭.
If its not working , try figuring out the reason, afterall you are a programmer.🙂
Do hit the follow button on GitHub. If our programs helped you in some way :)
yeah ok tqsm😊btw im not a programmer
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm not getting any output it's asking for data continuously