cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
ToUpper() and ToLower()
ToUpper() and ToLower()
Jun 8, 2014 at 9:12pm UTC
closed account (
jvqpDjzh
)
I would like to create my own ToUpper() and ToLower() functions (for my String class) without using STL support classes. The only idea that came out is to use the ASCII table, but is it a really good idea?
Thank you!
Jun 8, 2014 at 9:26pm UTC
Smac89
(1727)
There are bitwise operations you can use to create your own:
1
2
3
4
5
6
7
int
tolower(
int
ch) {
return
ch | 0x20; }
int
toupper(
int
ch) {
return
ch & 0x5f; }
Jun 8, 2014 at 10:31pm UTC
MiiNiPaa
(8886)
Also you should check range of input to avoid conversion of non-letters (or use isalpha() function)
Topic archived. No new replies allowed.