Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN LEX: Instructions: Modify the original code to count the times a number occurs. A letter(alphabet) is defined as [a-zA-Z]+ (don't use an array) 1.

IN LEX:

Instructions:

Modify the original code to count the times a number occurs. A letter(alphabet) is defined as [a-zA-Z]+ (don't use an array)

1. lex hw1.l

- new file called "lex.yy.c" should appear

compile the new file

gcc -o hw1 lex.yy.c

2 . execute hw1 as follows

./hw1 < /etc/passwd

and examine the output.

Code must run error-free and with no warning using UNIX/Linux.

CODE GIVEN:

 int lgths[100]; %% [0-9]+ lgths[yyleng]++; . | ; %% int yywrap() { int i; printf("Length No. Numbers "); for (i=1; i<100; i++) { if (lgths[i] > 0) { printf("%5d%10d ",i,lgths[i]); } } return(1); } main() { yylex(); }

*******************************************************************************************************************************************************

WHAT I HAVE DONE:

 int lgths[100]; int count; %% [a-zA-Z]+ lgths[yyleng]++; . | ; %% yywrap() { // need help writing count algorithm to count num of words (not in an array) int i; printf("Length No. Numbers "); for (i=1; i<100; i++) { if (lgths[i] > 0) { printf("%5d%10d ",i,lgths[i]); } } return(1); } main() { yylex(); }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems 12th Asian Conference ACIIDS 2020 Phuket Thailand March 23 26 2020 Proceedings

Authors: Pawel Sitek ,Marcin Pietranik ,Marek Krotkiewicz ,Chutimet Srinilta

1st Edition

9811533792, 978-9811533792

More Books

Students also viewed these Databases questions

Question

Describe the new structures for the HRM function. page 676

Answered: 1 week ago