45 lines
672 B
C
45 lines
672 B
C
#include <stddef.h>
|
|
|
|
size_t strlen(const char* str)
|
|
{
|
|
size_t len = 0;
|
|
while (str[len])
|
|
len++;
|
|
return len;
|
|
}
|
|
|
|
char to_upper_char(char c)
|
|
{
|
|
if ('a' <= c && c <= 'z') {
|
|
return c - 0x20;
|
|
} else {
|
|
return c;
|
|
}
|
|
}
|
|
|
|
char to_lower_char(char c)
|
|
{
|
|
if ('A' <= c && c <= 'Z') {
|
|
return c + 0x20;
|
|
} else {
|
|
return c;
|
|
}
|
|
}
|
|
|
|
char* to_lower_str(char* str)
|
|
{
|
|
for (size_t i = 0; i < strlen(str); i++) {
|
|
str[i] = to_lower_char(str[i]);
|
|
}
|
|
return str;
|
|
}
|
|
|
|
char* to_upper_str(char* str)
|
|
{
|
|
for (size_t i = 0; i < strlen(str); i++) {
|
|
str[i] = to_upper_char(str[i]);
|
|
}
|
|
return str;
|
|
}
|
|
|