 <p>You can use as mentioned below. You need a structure with an array of int.</p> <pre><code> struct Player { public int[] cards = new int[13]; }; </code></pre> <p>Then your while loop goes something like below</p> <pre><code>Palyer []player = new Palyer[4]; int random; int i = 1; while (i &lt;= 4) { cout &lt;&lt; "Card of Player " &lt;&lt; i &lt;&lt; " : "; int j = 0; while (j &lt; 13) { random = rand() % 52; if (player[i].cards[random] == NULL) { cards[random] = i; cout &lt;&lt; cardName(random) &lt;&lt; " , "; player[i].cards[j] = random; /* That's what I'm doubt with */ j++; } } i++; } </code></pre> <p>//Like the answer if it is helpful</p>