Let's say I have a string s:
Code:
string s = "How are YOU doING toDay?"
I want to convert this string so that only the first letter of each word is capitalized (so I want it to be: "How Are You Doing Today?"). I was thinking that it would be easier to first convert each letter to lowercase (using a string iterator and the tolower() function), and then capitalize the first letter of each word. But this is turning out to be more difficult than I thought. If it was just two words then I was thinking I can use substr() and find_first_of() to separate the words and capitalize each part, but the thing is I'm not guaranteed the number of words in the string. Any ideas are appreciated!