I'm trying to make a card-game, and my plan is to make an array that first holds 1-10, then J-A, then the colors, so three different arrays and different variables with ints and chars.
However, I'm stuck with the problem now that I want to remove duplicates from the array, but i dont really know how to do it, I've read some facts but I need a better explanatin and hur it would look code-wise.
This is how my code looks so far:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int arrays[10] = { 1,2,3,4,5,6,7,8,9,10 };
char* color[4] = { "Diamond", "Spade", "Heart", "Clubs" };
int i;
int *number;
srand(time(NULL));
for (i = 0; i < 10; i++) {
number = arrays[rand() % 10];
if (number ) { //Its here where i want to remove the duplicates
continue;
}
else {
printf("%d ", number);
}
}
system("pause");
return 0;
}
I would be greatly thankful for an explanation on how to do it, I tried with variables holding the value of arrays[i] but then all the numbers will be removed.