Generating a random array index?
<p>I have a <code>std::vector&lt;int&gt;</code> for enabled cards.
I want the computer to choose one at random:</p>

<pre><code>int r = 0;
r = rand() % m_enabledCards.size();
cardCount.push_back(m_enabledCards[r]);
</code></pre>

<p>For some reason this returns an index that is out of bounds and the vector has around 13 elements.</p>

<p>What could be wrong?</p>

<p>Thanks</p>
