| | |
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,829
Reputation:
Solved Threads: 501
0
#2 27 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 27 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: 169
Reputation:
Solved Threads: 10
0
#4 27 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,829
Reputation:
Solved Threads: 501
0
#5 27 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; 27 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: Opening Web page and control elements of the web.
| Thread Tools | Search this Thread |
api application array arrays based beginner binary c++ c/c++ calculator char char* class classes code compile compiler console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg simple sorting string strings temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






