473,473 Members | 1,918 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Can't convert to upper case (string)

2 New Member
Hi folks,,

I'm new here and having trouble to compile uppercase ....

and here is my code:
Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <string>
  3. #include <iomanip>
  4. #include <algorithm>
  5.  
  6. using std::cout;
  7. using std::cin;
  8. using std::endl;
  9. using std::string;
  10. using std::getline;
  11. using std::fixed;
  12. using std::setprecision;
  13. using std::transform;
  14. using namespace std;
  15.  
  16.  
  17.  
  18. int main()
  19. {
  20.     //declaring a variable
  21.     string state="";
  22.  
  23.     //getting the input
  24.     cout<<"Enter the State : "<<endl;
  25.     cin>>state;
  26.  
  27.  
  28.     //states=toupper(states);
  29.     transform(state.begin(), state.end(), state.begin(), toupper);
  30.  
  31.     //determain the state that the user input
  32.     if (state=="HAWAII")
  33.     {
  34.         cout<<"The shipping charge for Hawaii is $30.00. "<<endl;
  35.     }//end if
  36.     else if (state=="OREGON")
  37.     {
  38.         cout<<"The shipping charge for Oregon is $30.00."<<endl;
  39.     }//end else if
  40.     else
  41.     {//end else
  42.         cout<<"Incorrect State..";
  43.     }
  44.  
  45. return 0;
  46. }
  47.  
and this is the error knowing that I have Mingw as a compiler:

Expand|Select|Wrap|Line Numbers
  1.  ----jGRASP exec: g++ -g C:\Users\Conan9\Desktop\ChargeStates.cpp
  2.  
  3. C:\Users\ayman\Desktop\ChargeStates.cpp: In function `int main()':
  4. ChargeStates.cpp:29: error: no matching function for call to `transform(__gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, <unknown type>)'
  5. ChargeStates.cpp:46:2: warning: no newline at end of file
  6.  
  7.  ----jGRASP wedge2: exit code for process is 1.
  8.  ----jGRASP: operation complete.
  9.  


Please Help!!
Mar 1 '08 #1
5 3658
sicarie
4,677 Recognized Expert Moderator Specialist
Expand|Select|Wrap|Line Numbers
  1. int main()
  2. {
  3.     //declaring a variable
  4.     string state="";
  5.  
  6.     //getting the input
  7.     cout<<"Enter the State : "<<endl;
  8.     cin>>state;
  9.  
  10.  
  11.     //states=toupper(states);
  12.     transform(state.begin(), state.end(), state.begin(), toupper);
  13.  
What is toupper in the last line? It's not a function - you don't pass it anything or save the return value. It's not a variable, you haven't declared it... The line above it looks more correct than the last line...
Mar 1 '08 #2
weaknessforcats
9,208 Recognized Expert Moderator Expert
Your code works fine using Visual Studio.NET 2005. Hawaii gets converted to HAWAII just as you wish.

To Sicarie:

toupper is the address of the toupper(). The transform algorithm will call toupper() using each element of the container, in this case a char.

You are supposed to do this rather than code your own loop.
Mar 1 '08 #3
conan9
2 New Member
Your code works fine using Visual Studio.NET 2005. Hawaii gets converted to HAWAII just as you wish.

To Sicarie:

toupper is the address of the toupper(). The transform algorithm will call toupper() using each element of the container, in this case a char.

You are supposed to do this rather than code your own loop.

Thank you all,

However why is it not working when using Jgrasp??

Conan9
Mar 1 '08 #4
weaknessforcats
9,208 Recognized Expert Moderator Expert
You might try including <functional>. That's supposed to be included by <algorithm> but one never knows.
Mar 1 '08 #5
sicarie
4,677 Recognized Expert Moderator Specialist
To Sicarie:

toupper is the address of the toupper(). The transform algorithm will call toupper() using each element of the container, in this case a char.

You are supposed to do this rather than code your own loop.
Wow, I've never seen that. Thanks for the clarification.
Mar 2 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

23
by: Hallvard B Furuseth | last post by:
Has someone got a Python routine or module which converts Unicode strings to lowercase (or uppercase)? What I actually need to do is to compare a number of strings in a case-insensitive manner,...
2
by: Ebi | last post by:
Hi I'm writing a project in C++ borland 5; and I need a function that get a string or char* variable and convert all of the small letters to the capital. please help me. -- Sincerely Yours...
3
by: bob | last post by:
In vb6 you could say s = Format(s, "!") to force text to upper case in the format function. I've searched the vb.net help system and can't find any help on formatting text. There's plenty of help...
22
by: federico_bertola | last post by:
Hi everybody, I have an array of chars that I want to make all lower int Scan(char Search) { char *cPtr; cPtr = strtok (Search," -,."); while (cPtr != NULL) {
8
by: mesutalturk | last post by:
How do i convert the following C# code to Delphi? public static uint GenerateSiteID(string SiteName) { uint id = 0; char arr = SiteName.ToCharArray(); //Convert the sitename to a Char Array...
1
by: vv1 | last post by:
Write a C program for reading in a message string (with no blanks) and decoding the message. Store the decoded message in another string called outString. After decoding is complete, print...
0
by: vp1 | last post by:
Write a C program for reading in a message string (with no blanks) and decoding the message. Store the decoded message in another string called outString. After decoding is complete, ...
14
by: fniles | last post by:
In VB.NET 2005 can I check if a letter in a string is upper case or lower case ? For example: I have the following 2 lines: NQ,Z2003,11/11/2003,1416.5,1420,1402,1411.5...
4
by: titan nyquist | last post by:
Why does ToTitleCase not work if the case is already in upper case? I have to make my string lowercase, first, before I pass to to ToTitleCase to have it work. Titan
9
by: engteng | last post by:
How do I convert string to numeric in VB.NET 2003 ? Example convert P50001 to 50001 or 50001P to 50001 but if P is in middle then not convert. Regards, Tee
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.