Question: I was just wondering how this code works, I'm pretty new to coding and I was wondering how it works.

```

    for (int x = 0; x < 53; x++)
    {
        int h = rand() % 52;
        int j = rand() % 52;

        //   Randomize/shuffle deck
        Deck[52].face = Deck[h].face;
        Deck[52].suit = Deck[h].suit;
        Deck[52].value = Deck[h].value;

        Deck[h].face = Deck[j].face;
        Deck[h].suit = Deck[j].suit;
        Deck[h].value = Deck[j].value;

        Deck[j].face = Deck[52].face;
        Deck[j].suit = Deck[52].suit;
        Deck[j].value = Deck[52].value;
    }

```

Answer: 
Indexing starts at 0, so the bottom of the deck is Deck[51]. They're using position 52 as an ancillary container to make the switch between Deck[e] and Deck[i].
D. Kupra has given an answer which is the technical core of how doublicating cards is avoided. I add an answer which tries to help you visualise "what's happening in the background", because it might help you seeing beyond array indexes and variable assignments.

It works by doing 53 times a swap of two cards, in a spread deck, metaphorically using only one hand.

By "spread deck" I mean that all cards are distributed on a wide table, if you take one card away, an empty place remains. (This is in contrast to the usual method of having a deck of cards in your hands, which would act like a linked list data structure; where if you take a card the two adjacent cards close the gap.)  

By "using only one hand" I mean that you cannot keep one card while moving another one. You can only move one card from one place to another.  

Luckily, at the end of the table (see answer by D. Kupra), there is one place more than there are cards.

* pick two cards, by only memorising their position on the table

```
int e = rand() % 52;
int i = rand() % 52;

```

* move the first selected card to the (currently free) end place

```
Deck[52].face = Deck[e].face;
Deck[52].suit = Deck[e].suit;
Deck[52].value = Deck[e].value;

```

* move the second selected card to the now free place where the first selected card was

```
Deck[e].face = Deck[i].face;
Deck[e].suit = Deck[i].suit;
Deck[e].value = Deck[i].value;

```

* move the first selected card, from its current place at the end of the table, to the place where the second selected card was until recently

```
Deck[i].face = Deck[52].face;
Deck[i].suit = Deck[52].suit;
Deck[i].value = Deck[52].value;

```

At this point, you can still "see the card" which temporarily was at the end of the table, the metaphor is limping a little here....