I am working with a string being passed in from a client. I am comparing this string to a preset value.
In order to do this, I need to make the incomming string capital. I know toupper will only work on char.
How can I make a string all uppercase?
In C++:How do you make a STRING uppercase?
Not as such, but you can write one without much trouble.
void stoupper(std::string%26amp; s)
{
std::string::iterator i = s.begin();
std::string::iterator end = s.end();
while (i != end) {
*i = std::toupper((unsigned char)*i);
++i;
}
}
Reply:One other oddball suggestion. If you can store the preset value in a string, you can use the built in function compare. More information at the URL below. Pivy.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment