Skip to content
Sign upLog in
← Back to Community

expected expression error in c++

Profile icon
EricHofmann11

I am trying to create a program that will simply do calculations. However, when I try to prevent the user from inputting '' instead of '/'. I get the error message "if (opsign == '') expected expression ^

Voters
Profile icon
Ayrtontorres
Profile icon
EricHofmann11
Comments
hotnewtop
Profile icon
SixBeeps

The backslash is used for escaping characters in most languages. If you want to enter a backslash character in a string, you have to escape it (effectively escaping the thing that's used for escaping):

printf("\\"); // This outputs one backslash
Profile icon
EricHofmann11

@SixBeeps
could you please help me with my updated program? after I implemented your form of the forward slash, my next assignment was to use the same program, but with a switch statement. Once I did so, I started to get another error message saying multiple definitions of main.