Advertisement Jump to content
Sign in to follow this  

Using insert on a vector

This topic is 4891 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I know this is a really easy thing but I'm just a beginner. Hopefully someone can easily steer me in the right direction. I'm making a Blackjack game and I'm trying to insert a cut card into a deck (which is a vector of cards) at a specific spot. Here's the function. void Shoe::insertCutCard(void) { Card cutCard; int iRandomNum = rand(); int iFifthOfDeck = vCards.size() * (1/5); int iSeventhOfDeck = vCards.size() * (1/7); cutCard.iSuit = 0; cutCard.iValue = 0; cutCard.bFacingUp = false; int iCutPos = (iRandomNum % (iFifthOfDeck - iSeventhOfDeck) + iFifthOfDeck); vCards.insert(iCutPos, cutCard); } I believe that I need to use a iterator when using insert but I cant find a good way to make an interator equal iCutPos. Any help on the matter would be much appreciated.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!