Code Help

Trying to get this code to clear, but when the program runs, I am getting an error.

Here is the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
string getCategory() //Get the category.
{
char cchoice;
string category;

cout << "Please select a category that matches the bill: "
<< "Medical (M), House (H), Credit (C)";
cin >> toupper(cchoice);

do
{
switch(cchoice)
{
case 'M':	category = "Medical";
break;
case 'H':	category = "House";
break;
case 'C':	category = "Credit";
break;
default	:	cout << "Incorrect Selection, please try again!\n\n";
system("pause");
break;
}
}while ((cchoice != 'M') || (cchoice != 'H') || (cchoice != 'C'));
return category;
}


Here is the error that it is pulling:

1>c:\users\kenneth\desktop\bill organizer program\bill organizer\bill organizer\bill organizer.cpp(26) : error C2679: binary '>>' : no operator found which takes a right-hand operand of type 'int' (or there is no acceptable conversion)


Please help me to understand where I am making the mistake. Keep in mind, this is just the function out of a class.
Last edited on
Firstly, write your code between [cod3] and [/cod3] (replace '3' with 'e').
The operator>> takes as argument a reference. But you can't make a reference to a temporary variable,such as a toupper(choice).
You maybe want to do this:
1
2
cin>>choice;
toupper(choice);
Last edited on
Thanks Guzfraba!! That did the trick!! I new it would probably be something simple!!

And sorry about the code, this is my first time on the site, so didn't know about the coding format. I will try to remember this next time!!
Topic archived. No new replies allowed.