>> DAVID MALAN: Let's now refine this program a bit.
Wouldn't it be nice if there were a function called, say, islower that
could return true or false based on whether a given
character is lowercase?
Wouldn't it be even nicer if there were a function called toupper that
could convert a lowercase letter to uppercase?
>> Well, it turns out that both functions exist, and they're declared in a file
called ctype.h.
So let's add that file to my includes.
include ctype.h.
And now let's utilize both of those functions, replacing first my if
condition as follows.
if islower s bracket i, thereby returning true or false if the ith
character in s is a lower case letter.
And let's now replace my arithmetic expression here with simply toupper of
s bracket i, thereby returning the uppercase equivalent of the ith
character in s if it's lower case.
>> I'm going to leave my else block alone, because if the letter is not
lowercase, I still want to print it out unchanged.
And let's now compile this program.
Make [? capitalize1. ?]
Let's now run the program with capitalize1.
And let's now type a word like hello in all lowercase.
H-E-L-L-O, Enter, and it indeed prints in all uppercase.
>> Let's try one more scenario, though, this time inputting my own name with
the first letter, D, capitalized already, just in case I messed
something up in my own code with the capitalization of that char.
Enter, but no, DAVID in all caps prints this time as expected.