0

in the following code:

    switch(a)
    {

    case '+' :
        result=num1+num2;
    break;

    case '-' :
        result=num1-num2;
    break;

    case '*' :
        result=num1*num2;
    break;

    case '/' :
        result=num1/num2;
    break;

    case '^' :
        result=pow(num1,num2);
    break;

    default :
       cout << "Invalid operator" << endl;
    }

is the char pointer, and the error is: error: switch quantity not an integer...

ApproachingDarknessFish
  • 14,133
  • 7
  • 40
  • 79
  • I don't understand, is a a char or char pointer. If it's a char pointer, that would explain why you are getting an error – James H Nov 13 '14 at 18:43

1 Answers1

3

If a is a pointer, you cannot use it in the switch: you need to dereference it first - either like this

switch(*a)

or like this

switch(a[0])
Sergey Kalinichenko
  • 714,442
  • 84
  • 1,110
  • 1,523