I took my deck of Cards (class Card) and shuffled the. But every time i ran the program it gave me the same shuffled results....

void Deck::shuffleDeck()
{
	std::random_shuffle(deck.begin(), deck.end());
}

Recommended Answers

All 3 Replies

Did you call srand first?

commented: fast response +0

just realizes i forgot that. Is it just

srand(time(NULL));?

EDIT: Nvm, works now. Dumb mistake by me :P ty

Try:

void Deck::shuffleDeck()
{
        srand(time(NULL));    // Set seed for random numbers
    std::random_shuffle(deck.begin(), deck.end());
}

Cheers,
Erik

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.