 <p>Just use <code>std::find</code>:</p> <pre><code>bool bag::find(std::string item) { return std::find(arr, arr + 5, item) != &amp;arr[5]; } </code></pre> <p>I'm assuming <code>arr</code> is a C-style array until you say otherwise.</p>