You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this code, if no word input by the user matches sought, cin will be invalid after the loop, causing the expression cin to be false.
According to page 241,
Therefore, assert should be used only to verify things that truly should not be possible. It can be useful as an aid in getting a program dubugged but should not be used to substitute for run-time logic checks or error checking that the program should do.
As discussed above, it is definitely possible that cin may be evaluated as false after the loop, which is not a bug. So we should not use assert here. Instead, it should be within the program's logic to check if we have found a word matching sought, so an if statement will do.
The text was updated successfully, but these errors were encountered:
I do not agree with that
In this code, if no word input by the user matches
sought
,cin
will be invalid after the loop, causing the expressioncin
to be false.According to page 241,
As discussed above, it is definitely possible that
cin
may be evaluated as false after the loop, which is not a bug. So we should not use assert here. Instead, it should be within the program's logic to check if we have found a word matchingsought
, so an if statement will do.The text was updated successfully, but these errors were encountered: