• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

whats wrong with this function???

cycleman77

Senior member
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
 
is it possible that your case '\' is triggering the escape character, and it doesn't believe that that case has a close quote?
 
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;
}
}
 
Back
Top