I need help making a vector to shuffle the deck of cards randomly as well as picking a card from the top of the deck, then discard a card back into the deck. The program should then reshuffle after cards have been discarded back into the deck.

#include <iostream>
using namespace std;

int main(int argc, char* argv[])
{
	int deck[52];
	srand(time(0));
	int card;
	
	
	for (int i = 0; i< 52; i++)
    {
		deck[i] = i;
		cout << deck[i] << " ";
    }
	
	cout <<"\n" << endl;
	
	random_shuffle(&deck[0], &deck[52]);
	for (int p = 0; p< 52; p++)
    {
		cout << deck[p] << " ";

 }
	cout << "\n";
return 0;

Does what you have work? When that works well, what do you want to add next?

I want to write the code of how to draw from a deck of cards, then discard a card back into the deck.

And yes it works.

Please format your code properly. It will help you in the long run, and we won't get confused by misreading the code.

"draw from a deck of cards" is a little ambiguous. In detail, exactly what does it do? What happens to the deck?

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.