convert string to capital letters without toupper()

Hi, I was wondering if anyone can help me. I need to convert a string to capital letters without using toupper(). I was wondering if anyone can give me a hint on what to use or need to do? All my searches have only ever lead me to using the toupper(). Please help. Thanks in advanced.
Use the decdecimal values of ascii charters (see www.asciitable.com)

1
2
3
4
char c = 'g' ;
cout << c;
c -= ( 'a' - 'A');
cout << c;


gG
Last edited on
Wow!! thanks!!! that helped me a lot! but I just have a question, what does this part mean?

c -= ( 'a' - 'A');


Thank you again, Jikax!
Char 'a' equals int 97.
Char 'A' equals int 65.
Char 'g' equals int 103.

103 - ( 97 - 65 ) = 71

Int 71 equals char 'G'

You also could have used 'z'-'Z' .. Of just 32... It gives The same result...
oh ok... I understand it better now.. i didn't know it was possible to subtract the char value.. thanks so much again! :)
Topic archived. No new replies allowed.