0

I have figured out how to do some of this on my own, but I've spent over an hour just searching for the videos on the subject!

I have no idea where the uppercase was introduced, or where pulling letters out of a long "string" are.

There is plenty of material for pulling things out of argv, and stuff for the other assignments but where the heck is the instruction on uppercasing and chopping up getstring input for the initials assignment? It's the easiest one of them and I can't complete it or find those videos!

Again, not looking for help on the issue, looking for direction where those topics are.

0

I am using toupper().

To use this, you have to declare #include .

I am also newbie, so it is all I know.

0

To chop up the string you get back from GetString(), use a for loop and iterate over the string as if it were an array.

To make a character uppercase, you can use the toupper(), but you could also use char math like this:

printf("Uppercase of %c = %c\n", 'v', 'v' + ('A' - 'a');

You'd probably want to put a variable in there where I hard-coded 'v'.

Because the letters are in single quotes, C knows they're of type char, not strings, and chars can be treated like numbers... you can add and subtract them.

I don't remember the numerical values of the letters, but it doesn't matter here. The difference between each lowercase letter and its uppercase version is the same. So, you just need to add the difference between the uppercase and lowercase version of any letter.

In this case, toupper() would be easier, but I think they want us to get comfortable with char math.

1
  • This is how I handled it as well. Just to note, it is also important to check to make sure if each case is already an upper case, for example: ` if('a' <= 'v' <= 'z') { // Change to Uppercase }`
    – Sam
    Jul 24 '16 at 19:00
0

The primary method for uppercasing that is shown in CS50 is using the topper() function.

To utilize this, you need to use #include <string.h> at the top of your file.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .