














Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!















In Today Lecture
Multi-dimensional Arrays char multi [ 5 ] [ 10 ] ;
Placed sequentially in the memory 1st row 1st col 2nd row 1st col [0] [1] [2] [3] [4] [0] [1] [2] [3] [4] [0]^ [1]^ [2]^ [3]^ [4] 3rd row 1st col
*multi
Example 2
main ( ) { int multi [ 5 ] [ 6 ] ; int row , col ; int *ptr ; ptr = *multi ; for ( row = 0 ; row < 5 ; row ++ ) { for ( col = 0 ; col < 10 ; col ++ ) { multi [ row ] [ col ] = row * col ; } } Example 3
Example 3
Array of Pointers
Array of Pointers char *myArray [ 10 ] ;
Storing Pointers in Array of Pointers
argc argv ‘argc’ stands for a count of the number of arguments ‘argv’ stands for a vector of arguments
**Example 5 main ( ) { const char suit [ 4 ]= { "Spades“ , "Hearts“ , "Diamonds“ , "Clubs“ } ; 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 ) ; }
Shuffle Functions void shuffle ( int wDeck [ ] [ 13 ] ) { int row , column , card ; for ( card = 1 ; card <= 52 ; card ++ ) { do { row = rand ( ) % 4 ; column = rand ( ) % 13 ; } while( wDeck[ row ]| column ] != 0 ) ; wDeck [ row ] [ column ] = card ; } }