Choosing card from deck

I am working on a card game. I've been using rand() function to choose cards from deck, but this function has its weaknesses and game often dealt same cards. Algorithm was:
I've added stTime variable and changed do - while loop:
This helped.
What do you think?
- Code: Select all
#define DECK 52 // number of cards in deck
int cards[DECK]; // deck of cards
int choice; // index of chosen card
do {
choice = rand(52);
} while (cards[choice] == 0);
// set card attributes according to choice
choice = 0;
I've added stTime variable and changed do - while loop:
- Code: Select all
stTime t = getTime();
//...
choice = fmod((t.sec_utc + (int) rand(52)), 52);
This helped.

What do you think?
