Thread: array [x] [y] = z //??

  1. #1
    Registered User blight2c's Avatar
    Join Date
    Mar 2002

    array [x] [y] = z //??

    i'm reading from deitel & deitel 3rd ed, pg 337

    in the above array, is z copied into both subscripts?

    here's more of the code

    void shuffle (int wDeck [] [13])
    	int row, column;
    	for (int card=1; card<=52; card++)
    		{	row=rand() %4;
    			column=rand() %13;
    		while (wDeck [row] [column] != 0 );
    		wDeck [row][column] =card;//?

  2. #2
    Registered User
    Join Date
    Mar 2002
    No. The array is two dimesional. The x and y each contain the index number for its dimension, the two combined point to one cell. The assignment: array[x] [y]=z; puts z into that cell.

  3. #3
    think of the 2 d array as a checker board. Each squareof the checker board is refered to be a row and a column, but each square may hold any of a variety of things, in checkers it may hold nothing, a red or black checker or a red or black king. The same with the array. Each [x][y] combination represents a different "cell" or space or whatever you want to call it. Each "cell" or space can hold a variety of things, called z in the code you posted, depending on what the type of the array is.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 05-29-2009, 07:25 PM
  2. from 2D array to 1D array
    By cfdprogrammer in forum C Programming
    Replies: 17
    Last Post: 03-24-2009, 10:33 AM
  3. Replies: 6
    Last Post: 11-09-2006, 03:28 AM
  4. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  5. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 07:48 PM