i'm working on a simple card game and I'm having trouble envisioning how a loop that deals cards like a real dealer would look.

I don't have code that needs fixing yet, I'm just having trouble picturing what needs to happen in the loop control - before I've even started writing it.

I figure there will be 3 separate variables that are looping at different rates, but I'm not sure how to go about doing that.

I'll try to explain what I mean with quick examples.

So in theory, i'd have my deck of cards as an array:
deck_card[52]

Then my players (lets say there are 3 of them) would be setup as a 2d array. And if they could hold a maximum of 5 cards I'd use:
player[3][5]

So the simplest "deal" would probably be pulling the first 5 cards from deck_card and assigning them to player[0], the next 5 cards to player[1] and so on...
And since the deck has been shuffled, it's still random so that works fine.

But an actual dealer sends the first card to player one, the second card to player two... etc... going around the table.
Code:
deck_card[0] goes to player[0][0]
deck_card[1] goes to player[1][0]
deck_card[2] goes to player[2][0]
deck_card[3] goes to player[0][1]
deck_card[4] goes to player[1][1]
deck_card[5] goes to player[2][1]
deck_card[6] goes to player[0][2]
etc...
Looking at that, I'm not immediately seeing a pattern that could easily be plugged into a "for" loop. Is this a multiple loop problem, or is there a math algorithm that i'm not seeing?

If the number of players and the number of cards in each hand were dependent on the function arguments it gets even more confusing to me.

So what would that loop look like? 3 different variables incrementing at different rates, to different maximum values.


Also, am I wasting my time thinking about this? I mean, I have no idea how to start doing it, so maybe that's a sign. Should I just stick to "1st 5 cards to player one, 2nd 5 cards to player two"? I realize in general, simpler is better... this idea was just nagging me.

Plus, I'm a beginner to C so my knowledge is pretty low level.