pointers, arrays, and functions oh my (newbie Q)
I have this program i modified that shuffles strings representing a deck of 52 cards. I've made it so it only deals 5 cards... similar to poker. Basically, im trying to create a function that will determine whether the hand contains a pair, two pair, three/four of a kind, straight, and flush. As you can see in my incomplete function "handTester" i attempt to use an if structure to determine the first thing on my list: a pair. I am totally confused on what to put in the if statement's condition. Please help me :( !!
Code:
#include <iostream>
using std::cout;
#include <iomanip>
using std::ios;
using std::setw;
using std::setiosflags;
#include <cstdlib>
#include <ctime>
void shuffle( int [][ 13 ] );
void deal( const int [][ 13 ], const char *[], const char *[] );
int main()
{
const char *suit[ 4 ] =
{ "Hearts", "Diamonds", "Clubs", "Spades" };
const char *face[ 13 ] =
{ "Ace", "Deuce", "Three", "Four",
"Five", "Six", "Seven", "Eight",
"Nine", "Ten", "Jack", "Queen", "King" };
int deck[ 4 ][ 13 ] = { 0 };
srand( time( 0 ) );
shuffle( deck );
deal( deck, face, suit );
return 0;
}
void shuffle( int wDeck[][ 13 ] )
{
int row, column;
for ( int card = 1; card <= 52; card++ ) {
do {
row = rand() % 4;
column = rand() % 13;
} while( wDeck[ row ][ column ] != 0 );
wDeck[ row ][ column ] = card;
}
}
void deal( const int wDeck[][ 13 ], const char *wFace[],
const char *wSuit[] )
{
void handTester ( const int [][ 13 ], const char *[],
const char *[] );
for ( int card = 1; card <= 5; card++ )
for ( int row = 0; row <= 3; row++ )
for ( int column = 0; column <= 12; column++ )
if ( wDeck[ row ][ column ] == card )
cout << setw( 5 ) << setiosflags( ios::right )
<< wFace[ column ] << " of "
<< setw( 8 ) << setiosflags( ios::left )
<< wSuit[ row ]
<< ( card % 2 == 0 ? '\n' : '\t' );
cout << "\n";
handTester ( wDeck, wFace, wSuit );
void handTester ( const int tDeck[][ 13 ], const char *tFace[],
const char *tSuit[] )
{
if ( )
cout << "Pair";
}
}
PS i had no idea on what to declare in my created function. If you have any tips for me, i would greatly appreciate it.