Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: Code Help

  1. #1
    New Coder
    Join Date
    Feb 2014
    Posts
    11
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Question Code Help

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

    Here is the code:

    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.

  • #2
    New to the CF scene
    Join Date
    Feb 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Change this code..
    Code:
    cin >> toupper(cchoice);
    to this...
    Code:
    cin >> cchoice;
    cchoice=toupper(cchoice);


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •