Someone pleas help me. Thanks in advance!
Upper to Lower Case convertion in C++ (and the other way around)
Started by
Qodeus
, Feb 14 2006 04:27 PM
#1
Posted 14 February 2006 - 04:27 PM
Someone pleas help me. Thanks in advance!
#2
Posted 14 February 2006 - 05:36 PM
In the header file ctype.h ( C ) or cctype ( C++ ), there are toupper and tolower methods.
Hope this helps!
#include <iostream> #include <cctype> using namespace std; int main() { char ch = 'a'; ch = toupper(ch); cout << ch << endl; ch = tolower(ch); cout << ch << endl; }You could always write your own methods:
char toupper(char ch) { if (ch < 'a' || ch > 'z') { return ch; } return ch - ('a' - 'A'); } char tolower(char ch) { if (ch < 'A' || ch > 'Z') { return ch; } return ch + ('a' - 'A'); }
Hope this helps!
Edited by destin, 14 February 2006 - 05:38 PM.
#3
Posted 15 February 2006 - 08:08 AM
Thanks a lot man. It realy helped me!
Similar Topics
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users