// Get firstname/lastname
std::string firstname;
std::string lastname;
std::cout<<"Enter First Name? ";
std::cin>>firstname;
std::cin.ignore();
firstname.toupper(firstname.begin(), firstname.end());
std::cout<<"Enter Last Name? ";
std::cin>>lastname;
std::cin.ignore();
lastname = toupper(lastname);
I have tried using it as string.toupper()
and string = toupper(string) and neither are working, both
are returning different errors. I know now that it's suppose
to take an int..I thought I can pass a string and have it capitalize the
first letter. In this case I just have a word that I need capitalized.
Is this possible?
See that is the confusing part. I am not wanting the entire word to have upper case. I just want the FIRST letter. Like if you had a sentence..make the first letter of that sentence an uppercase. or in this case since it's a first name/last name just the first letter of the first/last name would need to be just uppercase and the rest lowercase (regardless of how the user enters it in. That is what confused me about toupper...it isn't doing it the way I was expecting.
thanks Duoas, I think my c++ tutorial is somewhat outdated (looking at the copyright date),hmmm 1879,, my next assignment is void functions on the abacus, and adding wooden sticks to a stack and figuring out FIFO methods, kinda like Jenga. Well at least 1879 was a good year for french wine, hehe.
What is a good current c++ beginners tutorial, I feel like I am falling behind because my tutorial doesnt include many current library functions to practice.
That
firstname[0] = toupper(firstname[0]);
worked perfectly. First off I didn't know you could access characters in a string using the array keys. I also didn't know that was how you passed it via toupper. That will help a lot. Thanks again.