P.1: The index result of a `std::find`-like loop needs to be initialized to -1.

pull/439/head
Michael Park 10 years ago
parent 21b28d91ef
commit 3b29134985

@ -370,7 +370,7 @@ The second version leaves the reader guessing and opens more possibilities for u
string val;
cin >> val;
// ...
int index = 0; // bad
int index = -1; // bad
for (int i = 0; i < v.size(); ++i)
if (v[i] == val) {
index = i;

Loading…
Cancel
Save