I can make a single char go from lowercase to uppercase, or vice versa. But what I'm trying to accomplish now is trying to turn a whole string. What I thought I would do was take the string as a char array[100 and process each letter with my method of turning a single char to uppercase or lowercase. I figured it was a lot harder/complicated than I thought.
Here's my attempt -
My FAILED attempt at creating a string case changer
1 2 3 4 5 6 7
inlinevoid STRING_TOLOWER (char letters[100])
{
for (int i = 0; i <= letters[100]; i++)
{
letters[i] = CHAR_TOLOWER(letters[i]);
}
}
My WORKING attempt for changing a letter case changer
1 2 3 4 5 6 7
inlinevoid CHAR_TOLOWER (char letter)
{
for (int i = letter + 0; i < 65 && i < 91; i - 32)
{
CHAR_TOLOWER(letter);
}
}
inlinevoid STRING_TOLOWER (char letters[100])
{
for (int i = 0; i <= 100; i++)//notice that you need the size
{
letters[i] = CHAR_TOLOWER(letters[i]);
}
}
Whithout knowing the size:
1 2 3 4 5 6 7 8 9
void STRING_TOLOWER (char* letters)
{
int i = 0;
while(true)
{
if ( letters[i] == '\0' ) break;
letters[i] = CHAR_TOLOWER(letters[i++]);
}
}