lowercase/uppercase string

Hi everyone!
I'm doing a 3 part assignment for my class and I'm having trouble coming up with how to do this function:
"down case all letters of the string, and then up case only the first character of the string"

I have searched the site and read some tutorials on how to do this, but I am still not understanding. I have my entire program written except for this part.

Would anyone be able to possibly explain how to do this?

Thank you for the help :)
There is a library function called tolower(), which returns the lowercase equivalent of character argument. So to convert a string to lower case you could do this
1
2
3
4
5
6
while (str[i])
  {
    c=str[i];
    putchar (tolower(c));
    i++;
  }


And then you can use toupper() to make the first character uppercase
Last edited on
closed account (j3Rz8vqX)
1
2
3
4
5
6
7
8
9
10
11
12
char c = 'A';//Upper case Alpha letter

c = c + ('a'-'A');//(97-65=32)... 'A' + 32 = 'a';

//c == 'a';//True;

//Adding the sum of ('a'-'A') to any character will cause it to become lower case character; or an inter value of 32.

//Likewise:
//Subtracting the sum of ('a'-'A') to any character will cause it to become upper case character; or an inter value of 32.

//Have fun 

http://www.asciitable.com/
Thank you guys for the responses! :) It works!
Last edited on
Topic archived. No new replies allowed.