Deck of Cards Vector help

Hi all, I'm trying to figure out how I can store all 52 cards in a vector without pushing everything back because it consumes a lot of time. Is it possible to add vectors with the 52 cards already? thanks

EDIT: I already have a deck of cards as an array however is it possible to transfer the array to a vector?

Here is my array code, help would be appreciated!
1
2
3
4
5
6
7
8
9
10
const int DECK_SIZE = 52;
string deckOfCards[DECK_SIZE] = {"AS","JS","2S","3S","4S"
,"5S","6S","7S","8S","9S"
,"10S","QS","KS",
"AC","JC","2C","3C",
"4C","5C","6C","7C","8C","9C","10C",
"QC","KC", "AH","JH","2H","3H","4H",
"5H","6H","7H","8H","9H","10H","QH","KH",
"AD","JD","2D","3D","4D","5D","6D","7D","8D",
"9D","10D","QD","KD" };
Last edited on
You mean something like:
1
2
3
4
5
6
7
8
9
10
11
12
13
    vector<string> deckOfCards = {"AS","JS","2S","3S","4S",
                                  "5S","6S","7S","8S","9S",
                                  "10S","QS","KS","AC","JC",
                                  "2C","3C","4C","5C","6C",
                                  "7C","8C","9C","10C","QC",
                                  "KC", "AH","JH","2H","3H",
                                  "4H","5H","6H","7H","8H",
                                  "9H","10H","QH","KH","AD",
                                  "JD","2D","3D","4D","5D",
                                  "6D","7D","8D","9D","10D",
                                  "QD","KD" };

    std::cout << deckOfCards.size() << endl;
Topic archived. No new replies allowed.