|
-
Nov 24th, 2002, 02:10 PM
#1
Thread Starter
Stuck in the 80s
String to Uppercase
How can I make sure a <string> is in all uppercase? I've found ways for char strings, but not <string> strings.
-
Nov 24th, 2002, 02:32 PM
#2
Thread Starter
Stuck in the 80s
is there any way to make them all uppercase?
-
Nov 24th, 2002, 02:33 PM
#3
Thread Starter
Stuck in the 80s
twanvl, you deleted your post.
-
Nov 24th, 2002, 02:37 PM
#4
Code:
#include <algorithm>
#include <string>
#include <locale>
#include <functional>
//...
std::string s;
if (std::find_if(s.begin(),s.end(),std::bind2nd(std::islower<char>,std::locale::clasic()))==s.end())
// all uppercase
else
// some lowercase
This should work
twanvl, you deleted your post.
Sorry, I found a mistake in my code.
-
Nov 24th, 2002, 02:38 PM
#5
Monday Morning Lunatic
Code:
#include <algorithm>
#include <string>
#include <iostream>
#include <cctype>
using namespace std;
int main() {
string s = "Hello world!";
transform(s.begin(), s.end(), s.begin(), (int(*)(int)) toupper);
cout << s << endl;
}
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Nov 24th, 2002, 02:43 PM
#6
Thread Starter
Stuck in the 80s
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|