// Program file: stringct.cpp // Demonstrates the use of the string class operators // by doug #include using namespace std; int main() { char hand[5][3]; // five cards each containing two chars and a null char card[3]; // one card containing two chars and a null char value[13] = {'2','3','4','5','6','7','8','9','T','J','Q','K','A'}; char suit[4] = {'S', 'H', 'C', 'D'}; // deal five cards without checking for duplicates for (int i = 0; i < 5; ++i) { int v = rand() % 13; // random numbers 0-12 int s = rand() % 4; // random numbers 0-3 card[0] = value[v]; // assign card value card[1] = suit[s]; // assign card suit card[2] = '\0'; // assign null to string strcpy(hand[i], card); // copy card to hand hand[i][2] = '\0'; // assign null to string } cout << endl; // print five cards in the hand for (int i = 0; i < 5; ++i) cout << hand[i] << ','; // one dimension is a card cout << endl; system("pause"); return 0; }