October 2004
Intermediate to advanced
336 pages
6h 27m
English
This function checks if two words are anagrams (which means that they have the same letters, but possibly in a different order). It ignores case differences in letters.
The program counts the letters in a string by allocating a 256-byte array and storing, in index n of the array, the number of times that the letter with an ASCII value of n appears (with an adjustment for case insensitivity—all letters are upper-cased first). This means that the program can't handle more than 256 of any one letter—that is not the bug. After the letter totals for the two words are counted, they are compared to see if they match, in ...
Read now
Unlock full access