1. ## shuffling cards

what kind of script do i have to put in a black jack program so that after every hand of blackjack it "reshuffles" the cards? im working on the random function but i am just terrible at it so any help will be greatful. i'm also working on an array filled with the cards and i know i need a pointer so that the random factor will can point randomlly at cards stored in the array im just struggling with it. so as you can read i need a lot of help so please.........

2. There are probably a lot of different ways to do this.

One way (probably non-optimal but it should work) would probably be to generate two random numbers and, since you say you're using an array, swap the elements at those two indexes.

To get a random number between 0 and an upper limit first get a random number, then you use the modulo operator on it with the right operand as the upper limit.

Make sure you seed the random number generator first with srand(time(0)).

Small example:

Code:
```char array[10];
int rand1 = rand() % 10;
int rand2 = rand() % 10;

Swap( array[rand1], array[rand2] );```
Then repeat.

3. Are you having trouble with the code or with ideas?

There are plenty of ways to shuffle a card deck. Some more realistic (in that they don't shuffle as fully), and some more random. How do you want to do it?

4. i want it pretty much to print out that it is shuffling and just put out 4 more random cards; two on one line and two on the next line. i am so lost on this blackjack program!!!!!!!!!

5. You don't need to use pointers for shuffling cards, at all. Just use an index or two, and make it easy on yourself.

random1 = rand() % 52; //range: 0 to 51, perfect!
repeat to get random2;

Now just swap random1 and random2: deck[random1], deck[random2].

And look ma! No pointers!!

You need to do this a lot, before the deck will really be shuffled thoroughly.

Note that although this is "OK random", this is NOT REALLY as random as it needs to be to play blackjack for money. As always with random in C, you need to first (and just once), seed the random number generator, before you do that:

srand();

Look that up in your compiler's help, yours will be different than mine. You need to include stdlib.h, also.

6. Originally Posted by gloworm
i want it pretty much to print out that it is shuffling and just put out 4 more random cards; two on one line and two on the next line. i am so lost on this blackjack program!!!!!!!!!
So make an attempt already! We aren't going to do it for you. If all you're going to do is tell us how hard it is, how much help you think you'll need, and how lost you are, then you aren't actually going to get anywhere towards helping yourself.

Show some code and walk us through where you think your lack of understanding is.