| | |
uppercase and lowercase
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Nov 2009
Posts: 8
Reputation:
Solved Threads: 0
Hey...
I've written a program that changes a single character from uppercase to lowercase and viceversa but I want to change a whole word from uppercase to lowercase and viceversa
how do I do that?
I've written a program that changes a single character from uppercase to lowercase and viceversa but I want to change a whole word from uppercase to lowercase and viceversa
how do I do that?
C++ Syntax (Toggle Plain Text)
#include <cctype> #include <iostream> using namespace std; int main() { for (int i=1;i<=10;i++){ char ch; cout<<"Enter a character: "; cin>> ch; if ( isalpha ( ch ) ) { if ( isupper ( ch ) ) cout<<"The lower case equivalent is "<< static_cast<char> ( tolower ( ch ) ) <<endl; else cout<<"The upper case equivalent is "<< static_cast<char> ( toupper ( ch ) )<<endl; } else cout<<"The character is not a letter"<<endl; while ( cin.get ( ch ) && ch != '\n' ) ; } system("pause"); return 0; }
•
•
Join Date: Jan 2008
Posts: 3,819
Reputation:
Solved Threads: 501
0
#2 19 Days Ago
Go through the word character by character and change each character to upper or lower case using toupper or tolower from cctype. There is no toupper or tolower function that takes a string as a parameter and converts the whole string.
I'm sure many people have written one, but it's not a standard function.
I'm sure many people have written one, but it's not a standard function.
0
#3 19 Days Ago
Here's mine:
c++ Syntax (Toggle Plain Text)
#include <iostream> #include <algorithm> #include <string> #include <cctype> struct upper { int operator() ( int c ) { return toupper ( static_cast<unsigned char> ( c ) ); } }; struct lower{ int operator() ( int c ) { return tolower( static_cast<unsigned char> ( c ) ); } }; int main(){ std::string str = "Test StrinG"; std::transform(str.begin(),str.end(),str.begin(),upper()); std::cout << str; std::transform(str.begin(),str.end(),str.begin(),lower()); std::cout << str; return 0; }
•
•
Join Date: Nov 2009
Posts: 153
Reputation:
Solved Threads: 7
0
#4 19 Days Ago
Which flavor of c++ are you using? I use VC++ for work and I use the MakeLower() function on strings.
Also, here's a dreamincode thread about a similar issue.
Also, here's a dreamincode thread about a similar issue.
•
•
Join Date: Jan 2008
Posts: 3,819
Reputation:
Solved Threads: 501
0
#5 19 Days Ago
•
•
•
•
Which flavor of c++ are you using? I use VC++ for work and I use the MakeLower() function on strings.
http://www.cplusplus.com/reference/
I know of no function in this set of functions that will do the job. But you're right. Visual C++ will have a lot of things beyond that. You can also look at the Boost functions. They could be in there too.
Last edited by VernonDozier; 19 Days Ago at 11:29 am.
![]() |
Similar Threads
- uppercase to lowercase url's (Search Engine Optimization)
- Finer points of Uppercase and Lowercase (C++)
- Validate String Can Be Both Uppercase or Lowercase (As in a Name) (C++)
- LC3 Uppercase and Lowercase (Assembly)
- Converting uppercase to lowercase help???? (Java)
- uppercase and lowercase HELP! (Java)
Other Threads in the C++ Forum
- Previous Thread: C++ Square Problem HELP
- Next Thread: calculator
| Thread Tools | Search this Thread |
api array arrays based beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete deploy developer dll download dynamiccharacterarray email encryption error file forms fstream function functions game getline givemetehcodez graph gui homeworkhelp homeworkhelper iamthwee ifstream input int java lib linker list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg sorting string strings temperature template text text-file tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






