problem with user input monitor

My program is working fine except I must take into account that the user may type the value -1 as first input.

In my idea, I should tell the program that if the user input -1 as first input and therefore the counter is 1 then program should stop. If the user already input other numbers (than means counter should be != 1) then program should run.

What happens now is that even if the user corretly input -1 after other previous inputs everything stops.

If I get rid of
1
2
3
4
5
if (double i = -1) && (counter = 1)
{
return 0;
}
else...

my program works fine...
Last edited on
closed account (S6k9GNh0)
if (double i = -1) && (counter = 1)

These are not condition expressions. Clearly the correct way is too use the '==' operand. It gives you the error because 'double i = -1' is an assignment expression and expects a semi colon.

if (double i == -1) && (counter == 1)

If you don't understand the difference between == and = , this can very easily be found in the CPlusPlus.com reference and tutorial section.
Last edited on
also, the whole conditional statement should be between parenthesis. And I'm not sure why you're initializing a double to -1 inside the conditional, I think you may want
if (scores[0] == -1)
even if (double i == -1) && (counter == 1) is wrong as double i is a declaration and you have to parenthesise the entire condition:
if ( scores[counter]==-1 && counter==1 ) ( I suppose that 'i' was meant to be 'scores[counter]'

(EDIT: typed slowly)
Last edited on
Topic archived. No new replies allowed.