I'm sure you've all seen it a hundred times - Get a phone number in letters, convert it to numbers, have a hyphen after the third number, and ignore spaces... Here's what I've got so far - it loops fine, displays nearly everything correctly, but it's not pulling the numbers the way I need it to - what am I doing wrong?
The cases 1 through 0 are there in case the telephone number entered is similar to 555-CALL, etc. Are those breaking the rest of my program? or is it just the "tempNum = tempNum + 1" parts?
take advantage of the fact that '0'-48=0, 'a'-32='A', and that 'A'+1=66, 'B'+1 =67 and 'C'+1 = 68 and that any of these divided by 3 is equal to 22. This logic works for converting the rest of the alphabet, up through and including 'R'. You would have to a subtract 0 or 1 for numbers after that. This is assuming that you are using ASCII; however, I believe that unicode is backward compatible with ASCII, so this shouldn't be too much of a problem.
FYI, tempNum = tempNum + 1; is the same as tempNum += 1;
Also, you don't have to use both uppercase and lowercase letters in your cases. You can use tolower() or toupper() on the char before the switch statement, and only use either upper or lower case letters. Kills off a lot of redundancy that way.
and I'm not totally positive, but I believe numCount = ++numCount; is equivelent to numCount++;
And also, if you wanted to, you could do tempNum++ instead of tempNum += 1 or tempNum-- instead of tempNum -= 1