This is not likely ever to be true.
*str != EOF
The first loop goes to the end of file, right? Then the second loop never has anything to read, right?
When do you expect to get anything different for this?
if (97 <= (static_cast<int>(tolower('a'))) <= 122)
alphabet[static_cast<int>('a') - 97]++;
That is, when will'a' not be between 'a' and 'z' (in ASCII)?
Arrays are indexed from 0 to N-1, not 1 to N.
for (int i = 1; i <= 26; i++)
For a 26-element array, the elements would be from 0-25.
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
>This is not likely ever to be true.
You mean false? I'd say it's highly likely to be true since EOF must be a negative quantity and characters gathered from a narrow stream must fit within an unsigned char. Fortunately, the other half of the condition will cause the loop to terminate properly.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
>>This is not likely ever to be true.
>You mean false?
Uh, yeah. Parse error between monitor and chair.
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
>Uh, yeah. Parse error between monitor and chair.
Wetware compilers are so unreliable. Sounds like you need an upgrade. ;)
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
>>Uh, yeah. Parse error between monitor and chair.
>Wetware compilers are so unreliable. Sounds like you need an upgrade. ;)
Perhaps. But I know I need to get rid of this darn virus -- I've had it for almost two weeks. (Me and the baby and the wonders of day care keep passing it around in mutated forms methinks.)
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314