toupper syntax

Apr 15, 2009 at 10:40pm
I've come across the following code in the book I'm studying. I think this is a typo but I wanted to make sure I'm not missing anything.

=================================================================
char c;

cout << "Please enter A to add a purchase order,\n"

<< "P to process a PO, or Q to quit.\n";

while (cin >> c && toupper != 'Q')
=================================================================

Now from what I know that looks like an incomplete use of toupper. I looked up its signature and it looks to me like it needs to be given input in the syntax of toupper(int c). Is there a concept happening here I'm not getting or is this just a typo?

Thanks,
D
Apr 15, 2009 at 11:54pm
hmmm I've never seen any code like that before. And yes, toupper is used like that, excepts its a char not an int. I've done an example here: http://www.cplusplus.com/forum/beginner/9990/
Apr 16, 2009 at 12:27am
Sigh... it makes it so hard when I run into stuff like this:

http://www.cppreference.com/wiki/c/string/toupper

I threw the complete code into VC++ 2008 express and it surely didn't compile until i edited it to give an argument to toupper. Guess its just a typo then.
Apr 16, 2009 at 12:54am
A character is actually an integer (ascii value). That is no typo.
Apr 16, 2009 at 5:49am
No just so I keep my facts straight a char value doesn't have to be absolutely equal to an int does it? The char type and int type both do hold numbers but the char type isn't capable of representing as many numerals as an int correct?

I made a big check in my brain about char and int being actually dis-similar in memory size and capability. Hope i got that right.
Apr 16, 2009 at 12:32pm
the char type isn't capable of representing as many numerals as an int correct?
You're right:
1 char = 1 byte = 8 bit = (unsigned) range: [0,28)
1 int = (depends) more than 1 byte => Much more numbers
Topic archived. No new replies allowed.