-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCharFunctions.cpp
More file actions
49 lines (41 loc) · 832 Bytes
/
CharFunctions.cpp
File metadata and controls
49 lines (41 loc) · 832 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//
// Created by T Alpha 1 on 10/29/2019.
//
#include "CharFunctions.h"
bool isupper(char c) {
return c >= 'A' && c <= 'Z'; // incorrect 'A' <= c <= 'Z
//('A' <= c) <= 'Z;
//true or false <= Z;
//0 or 1 <= 'Z'
//0 or 1 <= 90
// true
//'A' + 1
//'C' - 'A'
}
bool islower(char c) {
return c >= 'a' && c <= 'z';
}
bool isalpha(char c) {
return islower(c) || isupper(c);
}
bool isdigit(char c) {
return c >= '0' && c <= '9';
}
bool isalnum(char c) {
return isalpha(c) || isdigit(c);
}
char toupper(char c) {
if(islower(c)){
return 'A' + (c - 'a'); //(c-a) is how far c is into the lowercase alphabet
//we then need to move that same amount into the uppercase alphabet
}else{
return c;
}
}
char tolower(char c) {
if(isupper(c)){
return 'a' + c - 'A';
} else{
return c;
}
}