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.
A name is a letter or underscore, then any letters, digits and underscores, other than the 32 C keywords; skip names in string and character constants, /* */ comments and lines starting with #, and the letters in numbers such as 0x1F. Upper and lower case differ. With the argument -n, use n characters instead of 6. Group the distinct names of at least that many characters by their first n characters, and print each group of two or more on a line of its own, its names in alphabetical order (as strcmp orders them) separated by blanks; the groups are in alphabetical order too. Names are at most 100 characters.
No submissions yet