next up previous
Next: Exercise 2. Up: Quiz9 Previous: Guidelines.

Exercise 1.

Complete the first two sections of the following LEX program such that it generates a scanner which counts the number of characters and the number of lines in its input file. This scanner produces no output other than the final report on the counts.

Answer 1  
%%






%%


main()
     {
     yylex();
     printf( "# of lines = %d, # of chars = %d\n",
            num_lines, num_chars );
}


next up previous
Next: Exercise 2. Up: Quiz9 Previous: Guidelines.
Marc Moreno Maza
2004-12-02