View Single Post
  #1 (permalink)  
Old July 5th, 2007, 03:07 AM
mor3bane mor3bane is offline
Registered User
 
Join Date: Jul 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default unwanted conversion from char to ascii

hi, from this code as input
[source]
char get_op( )
{
    char result;

    do
    {
        cout << "Please enter an operator for the expression node: ";
        cin >> result;
        cout << result << " has been read." << endl;
    }while(strchr("+-*/", result) == NULL);

    return result;
}
[/source]
to this code as implementation:
[source]
template <class Item>
       void expression<Item>::insert_left(const char op, const Item& entry)
    {

        if(root_ptr == NULL)
        {
            root_ptr = new exp_tree_node<Item>(op);
            root_ptr->set_left(new exp_tree_node<Item>(entry) );
        }

    }
[/source]

when op is accessed and displayed it shows as ascii and not the intended operator(+-*/) any idea why this is happening??
Reply With Quote