| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Distribution
Hi ,
I want to make a cards that distribute cards for 4 players. deck[5][20] is arrays of stings that have the name of the cards. the first card (from deck)goes to the first player, the second card (from deck) to the second player, the third card to the third player... until each player has 5 cards this is my approach: Code:
for(j=0;j<5;j++)
{ for(i=0;i<19;i=i+5)
{ hand1[j][20]=deck[i][20];
hand2[j][20]=deck[i+1][20];
hand3[j][20]=deck[i+2][20];
hand4[j][20]=deck[i+3][20];
}
}
then I have to print each hand. The code compiles well but it prints gibberish. Please, do you know how to fix it? thank you B |
|
#2
|
|||
|
|||
|
try taking the [20] away (all 8 occurrences of it). I think you assigning the last character of the string in the deck to the last character of the string in the hand, not the whole string as you intended.
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > Distribution |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|