I want to write a program in which the user enters a string and the program converts the input into uppercase.
For example, say the user enters "January" and i store it into a string type variable, how do I change it into "JANUARY"?
I want to write a program in which the user enters a string and the program converts the input into uppercase.
For example, say the user enters "January" and i store it into a string type variable, how do I change it into "JANUARY"?
Loop over each character of the string and call toupper on it:
Code:#include <cctype> #include <string> using std::string; using std::toupper; for (string::size_type i = 0; i < str.length(); i++) str[i] = toupper(str[i]);
Kampai!
I am a beginner( newbie) and I have no idea what that program does. Can u explain it to me?
It would help to see what code you have already so that I can help you write something a bit simpler. If you're a beginner than I don't imagine you're using C++ string objects.
Kampai!