I am working on a school assignment. What I want to do is not the focus of the assignment, merely something I would like to do better.
I have the following if statement where equation is a string
if( (equation[0]== "*") || (equation[0]== "/") || (equation[0]== "+") || (equation[0]== "-"))
All it does is check to see if the first and last characters of the string are one of 4 operators. This is long, bulky, and hopefully not the best way of doing this. Sadly I do not have access to regular expressions as this type of check would be very easy using them.
Is there a better way of writing the if statement without using regular expressions? Something along the lines of
if( equation[0] == ("/" || "*" || "+" || "-"))