String case: Difference between revisions

Content deleted Content added
Nick (talk | contribs)
add 4D
No edit summary
Line 22: Line 22:
Put_Line(To_Lower(S));
Put_Line(To_Lower(S));
end Upper_Case_String;
end Upper_Case_String;

==[[C plus plus|C++]]==
[[Category:C plus plus|C++]]

'''Standard:''' [[C plus plus|ANSI C++]]

'''Compiler:''' [[GCC]] g++ (GCC) 3.4.4 (cygming special)

'''Library:''' STL

This method does the transform in-place. Alternate
methods might return a new copy or use a stream manipulator.

/// \brief in-place convert string to upper case
/// \return ref to transformed string
void str_toupper(std::string &str) {
std::transform(str.begin(),
str.end(),
str.begin(),
std::toupper);
}


/// \brief in-place convert string to lower case
/// \return ref to transformed string
void str_tolower(std::string &str) {
std::transform(str.begin(),
str.end(),
str.begin(),
std::tolower);
}


here is sample usage code:

#include <iostream>
using namespace std;
int main() {
string foo("_upperCas3Me!!");
str_toupper(foo);
cout << foo << endl;
str_tolower(foo);
cout << foo << endl;
return 0;
}



==[[C#]]==
==[[C#]]==
Line 29: Line 76:
System.Console.WriteLine(array.ToUpper());
System.Console.WriteLine(array.ToUpper());
System.Console.WriteLine(array.ToLower());
System.Console.WriteLine(array.ToLower());

==[[C#]]==
[[Category:C_sharp]]

string array = "alphaBETA";
System.Console.WriteLine(array.ToUpper());
System.Console.WriteLine(array.ToLower());



==[[Forth]]==
==[[Forth]]==