I think your problem is related to numbers like 215. You think this is two hundred and five.
By the way, here is the correct python solution I wrote (sorry for not doing this in C):
numWords = {1: 3, 2: 3, 3: 5, 4: 4, 5: 4, 6: 3, 7: 5, 8: 5, 9: 4, 10: 3, 11: 6, 12: 6, 13: 8, 14: 8, 15: 7, 16: 7, 17: 9, 18: 8, 19: 8, 20: 6, 30: 6, 40: 5, 50: 5, 60: 5, 70: 7, 80: 6, 90: 6, 100: 7, 1000: 8, 0: 3} def get_count(number): if number==0: return 0 if number > 99: return get_count(number / 100) + len("hundred") + ((len('and') + get_count(number % 100)) if (get_count(number % 100)) else 0) if number > 20: return numWords[(number / 10)*10] + get_count(number % 10) return numWords[number] print sum(get_count(x) for x in xrange(1,1000))+len('one thousand')
You can see it much shorter than yours. The main improvement, in my opinion, is the use of recursive method calls. This would prevent you from falling into trouble with 215, since recursion processes 200 and 15 separately.