ch should be int if you want to test for EOF, and you have portability issues with such constructs as ch-'A'. I've seen worse, but you have some learning to do before I'd recommend posting examples for others to learn from.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
>May i know what type of portability issue with ch-'A' ?
There's an implicit presumption that the letters ['A'-'Z'] or ['a'-'z'] are consecutive. It's a very common failure amongst people who have only ever worked with ASCII or the lower seven bits of Unicode. The usual counter example is EBCDIC, where the latin alphabet characters are not adjacent.
For example, 'i' has a value of 137 in EBCDIC, but 'j' has a value of 145. Using the ch-'a' pattern, you would end up with incorrect values and probably an out of range access in the case where the result is used as an array index and the array size doesn't account for such a direct character set to index conversion when there's "dead space" in the character set.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401