Re: K&R Exercise 6-2



mdh wrote:
In most of the exercises that K&R write, there seems to be a
relationship to some library function or some aspect of C that is used
later. So, quick question to those more experienced programmers. Other
than this being an illustration of the use of structs, is this
illustrative of some aspects of C that you use all the time.
Thanks as usual.

Exercise 6-2
Write a program that reads a C program and prints in alphabetical
order each group of
variable names that are identical in the first 6 characters, but
different somewhere thereafter. Don't count
words within strings and comments. Make 6 a parameter that can be set
from the command line.

The exercise seems designed to point out the difference
between strcmp() and strncmp(), in the context of a comparison
function for qsort(). So there's certainly a library tie-in,
if that's what you felt was missing.

--
Eric Sosman
esosman@xxxxxxxxxxxxxxxxxxxx
.



Relevant Pages

  • Re: Comment on trim string function please
    ... 10 characters one position forward. ... library function that moves one byte at a time just like your loop, ... OK, we're STILL not up to a "billion" cycles, and I specifically covered ... library function that uses a few machine ...
    (comp.lang.c)
  • K&R Exercise 6-2
    ... In most of the exercises that K&R write, ... relationship to some library function or some aspect of C that is used ... variable names that are identical in the first 6 characters, ... words within strings and comments. ...
    (comp.lang.c)