whats wrong with this function???

cycleman77

Senior member
Jan 16, 2001
352
0
0
I have another project due this thursday for a CS class and I am having trouble with it.
This program worked last night and I didn't even change computers. I know it isnt finished yet, but it should still work so far. Here is a function where Visual gives me errors for all breaks and almost all case statements. There is one exception to the case statement probelm; the very first one does not get an error. The errors just say "Illegal 'case/break'".
Am i missing something???

void characterSort(int characters)
{
//Determines what character gets pushed.
switch(characters)
case '=':
opStack.push('=');
break;
case '+':
opStack.push('+');
break;
case '-':
opStack.push('-');
break;
case '*':
opStack.push('*');
break;
case '/':
opStack.push('/');
break;
case '%':
opStack.push('%');
break;
case ' ':
break;
case '(':
opStack.push('(');
break;
case ')':
while (opStack.top()!='(')
postFixQ.push(opStack.top());
opStack.pop();
break;
default:
postFixQ.push(characters);
break;
}
//end characterSort
 

oog

Golden Member
Feb 14, 2002
1,721
0
0
is it possible that your case '\' is triggering the escape character, and it doesn't believe that that case has a close quote?
 

Kntx

Platinum Member
Dec 11, 2000
2,270
0
71
void characterSort(int characters)
{
//Determines what character gets pushed.
switch(characters)
{
case '=':
opStack.push('=');
break;
case '+':
opStack.push('+');
break;
case '-':
opStack.push('-');
break;
case '*':
opStack.push('*');
break;
case '/':
opStack.push('/');
break;
case '%':
opStack.push('%');
break;
case ' ':
break;
case '(':
opStack.push('(');
break;
case ')':
while (opStack.top()!='(')
postFixQ.push(opStack.top());
opStack.pop();
break;
default:
postFixQ.push(characters);
break;
}
}