Skip to content

Latest commit

 

History

History
10 lines (7 loc) · 401 Bytes

5.4.md

File metadata and controls

10 lines (7 loc) · 401 Bytes

(a) The loop variable iter did not initialized before used. It should be initialized first.

string::iterator iter = s.begin();
while (iter != s.end()) { /* ... */ }

(b) The loop variable status is used outside the scope of the while statement, thus it should be defined outside that scope.

bool status;
while (status = find(word)) { /* ... */ }
if (!status) { /* ... */ }