val += line[i] == " * ";
is evaluated as val += (line[i] == " * ");
due to operator precedence.
val
will be incremented by 1 (true
converts to an integral value of 1) if, and only if, line[i]
compares true
with " * "
, else it will stay the same.
Finally #define endl '\n'
is very naughty. Don’t attempt to change symbols in the C++ standard library.
1
solved URI 1848 solution [closed]