Trouble displaying output

This is a discussion on Trouble displaying output within the C++ Programming forums, part of the General Programming Boards category; hi, here i would like to display each suite in order from smallest card to largest card suite by suite. ...

  1. #1
    Registered User
    Join Date
    Aug 2003
    Posts
    71

    Trouble displaying output

    hi,

    here i would like to display each suite in order from smallest card to largest card suite by suite.
    i thought i did everything right, but i dont receive any output on the screen. can anyone give me a hand please?

    Code:
    #include<iostream>
    #include<conio.h>
    using namespace std;
    
    #include<iomanip>
    #include<cstdlib>
    #include<ctime>
                                           // function deal prototype
    void deal( const int [][ 13 ], const char *[], const char [] );
    
    int main()
    {
       // initialize suit array
       const char suit[ 4 ] =       // you only need const char
          { 3, 4, 5, 6 };
    
       // initialize face array
       const char *face[ 13 ] =
          { "A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K" };
    
       // initialize deck array
       int deck[ 4 ][ 13 ] = { 0 };
    
    
    
       deal( deck, face, suit );
    
       getch();
       return 0;  // indicates successful termination
    
    } // end main
    
    
    // deal cards in deck
    void deal( const int wDeck[][ 13 ], const char *wFace[ 4 ],
               const char wSuit[ 4 ] )
    {
       // for each of the 52 cards
       for ( int card = 1; card <= 52; card++ )
    
          // loop through rows of Deck
          for ( int row = 0; row <= 3; row++ )
    
             // loop through columns of Deck for current row
             for ( int column = 0; column <= 12; column++ )
    
                // if slot contains current card, display card
                if ( wDeck[ row ][ column ] == card ) {
                   cout << setw( 5 ) << right << wFace[ column ]
                        << setw( 8 ) << left
                        << wSuit[ row ]
                        << ( card % 4 == 0 ? '\n' : '\t' );
    
                } // end if
    
    } // end function deal

  2. #2
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    You're testing wDeck for values when you haven't placed anything in it:

    Code:
    int deck[ 4 ][ 13 ] = { 0 };
    deal( deck, face, suit );
    I don't really understand what you're trying to do here so I don't know how you want to fill the deck array, but that's your problem.
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. strange virtual function output
    By George2 in forum C++ Programming
    Replies: 4
    Last Post: 02-08-2008, 08:08 AM
  2. Basic C input output program help
    By trevordunstan in forum C Programming
    Replies: 2
    Last Post: 01-27-2008, 06:41 PM
  3. 2d game
    By JordanCason in forum Game Programming
    Replies: 5
    Last Post: 12-08-2007, 10:08 PM
  4. Trying to store system(command) Output
    By punxworm in forum C++ Programming
    Replies: 5
    Last Post: 04-20-2005, 07:46 PM
  5. sorting output on student info program
    By indigo0086 in forum C++ Programming
    Replies: 2
    Last Post: 11-05-2002, 11:29 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21