View Single Post
Old 06-13-2006, 01:23 PM   #1 (permalink)
FloydianOne
Crazy
 
[C] 2d array pointers

Can someone either explain to me, or give me a good site to learn how to do the following?


If I have an 2d array..
int [2][3] = {1,2,3,4,5,6};

How do I pass the array into a function which will switch the rows?
ie... row 0 is now row 1 and row 1 is now row 0.

I know its something to do with pointers and double pointers, and I tried to read a few sites about them... but it just ended up confusing me more, none of them had any good examples.

I thought it would be something like this...
Code:
	int array[2][3] = {1, 54, 98, 2, 75, 84};
	
	int **temp1;
	int **temp2;
	
	int *t;
	t = array[0][0];
	*temp1 = array[1][0];
	*temp2 = t;
Thanks for any help..
__________________
Fight apathy! ..... or dont.

Last edited by FloydianOne; 06-13-2006 at 01:31 PM..
FloydianOne is offline  
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73