Sep 22, 2013 at 4:30am UTC
On line 44, it says to keep looping only while exit is equal to y. It should be:
} while (exit != 'Y' || exit != 'y' )
Sep 22, 2013 at 4:39am UTC
I originally had it like that, it just continued looping. Tried it again just to make sure and I can verify that it just keeps looping.
Last edited on Sep 22, 2013 at 4:40am UTC
Sep 22, 2013 at 4:49am UTC
It should be:
while (exit != 'Y' && exit != 'y' )
Note that the original code:
while ( exit == 'Y' || 'y' )
will always evaluate to true because it is equivalent to:
while ( (exit == 'Y' ) || 'y' )
and since 'y' is non-zero, 'y' evaluates to true.
In the line provided by retsgorf297, while ( exit != 'Y' || exit != 'y' )
,
we can take a look at the expression when exit is 'Y' to see why it doesn't work:
while ( 'Y' != 'Y' || 'Y' != 'y' )
which is equivalent to:
while ( false || true )
which simplifies to:
while (true )
Last edited on Sep 22, 2013 at 4:50am UTC
Sep 22, 2013 at 5:08am UTC
Thank you very much cire, it worked but i'm a little confused.
I originally had while ( exit != 'Y' || exit != 'y' )
why won't making the statement true exit the loop?
From what i was understanding i thought the statement would read while exit is not Y or y continue (false), but if it is Y or y (true) exit.
Last edited on Sep 22, 2013 at 5:09am UTC