Not sure why this won't work

Jan 30, 2011 at 12:19am
It goes into the loop, so I think that the problem is my conditional operator. Can I not use function calls in it? Here is the code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
#include <cctype>

int main()
{
	using std::cout;
	using std::cin;
	char ch;
	cin.get(ch);
	while (ch != '@')
	{
		if (!(isdigit(ch) && isxdigit(ch)))
		{
			if (isalpha(ch))
				isupper(ch) ? tolower(ch) : toupper(ch);  //Think problem is here, it goes into the second
                                                                                     // if correctly, but it doesn't seem to do this part.
			cout << ch;
		}
		cin.get(ch);
	}
	return 0;
}


Any help would be appreciated. I'm sure its something simple that I'm overlooking.

EDIT: telling you what the program is meant to do might help. It is supposed read keyboard input to the @ symbol, echo that input excluding digits, also converting each uppercase character to lower and vice versa. Its that last part that is proving difficult.
Last edited on Jan 30, 2011 at 12:25am
Jan 30, 2011 at 12:41am
if(isalpha(ch)) ch = (isupper(ch) ? tolower(ch) : toupper(ch));
Last edited on Jan 30, 2011 at 12:41am
Jan 30, 2011 at 12:44am
oh. Yeah, that might make a difference. thanks. *walks away feeling one point dumber*
Last edited on Jan 30, 2011 at 12:45am
Topic archived. No new replies allowed.