Hi there. I'm pretty new to C++ and need some help. I'm attempting to create a calculator but I get 12 errors when I compile it. So could anyone tell me what's wrong with this?
This is what my compiler tell me is wrong. input is a string.
1 2 3 4 5
for (int i = 0; i =< input.size(); i++)
{
if ((input[i] == "+") || (input[i] == "-") || (input[i] == "*") || (input[i] == "/"))
arithmeticOperators += 1;
}
The first thing I see is a problem with the bigger than or equal to operator. It should be <= instead of =<.
As firedraco said, replace the quotation marks for single quotes.
I don't know if you declare the array, so you need to display the whole code and the error report.
" are for character sequences, eg: "hello world"
' are used for single character, eg: 'A'.
You can use single quotes for multi-character constants but this is useless: int i = 'wtf?';