Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C > Re: Two dimensi...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 20 of 32 Topic 26121 of 26977
Post > Topic >>

Re: Two dimensional array Question

by mdh <mdeh@[EMAIL PROTECTED] > May 11, 2008 at 07:07 PM

On May 11, 4:17=A0am, Barry Schwarz <schwar...@[EMAIL PROTECTED]
> wrote:
> On May 9, 8:35=A0pm, mdh <m...@[EMAIL PROTECTED]
> wrote:
>
>
> Depending on the type of p. =A0If arr is defined as T arr[N][M], then
> for your code to be legal, p must be a T**. =A0*p will then have type T*
> and arr[i] will be converted to &arr[i][0] which is also of type T*.
>
> Far more common is for p to be a T* and the assignment to read
> p =3D arr[i].


Well...I **think**  I see it a little more clearly.
Although once admonished for writing code to figure things out, a weak
attempt follows.

#include <stdio.h>

int main (int argc, const char * argv[])
	{
	int i, j, k, l;
	char arr [3][3] =3D {"One", "Two", "Lst"};
	char *p;
	char **q;

	for ( i =3D 0; i < 3; i ++)
		for ( j=3D 0; j < 3; j++)
		{
		p=3D&arr[i][j];
	printf( "%p\n", p);
		}

	putchar('\n');

	for ( k =3D 0; k < 3; k ++)
		for ( l=3D 0; l < 3; l++)
		{
			p=3Darr[k];
			q=3D&arr[k][l];
		printf( "%s %s\n", p, q);
		}
	}
output:

0xbffff7cf
0xbffff7d0
0xbffff7d1
0xbffff7d2
0xbffff7d3
0xbffff7d4
0xbffff7d5
0xbffff7d6
0xbffff7d7

OneTwoLst=03 OneTwoLst=03
OneTwoLst=03 neTwoLst=03
OneTwoLst=03 eTwoLst=03
TwoLst=03 TwoLst=03
TwoLst=03 woLst=03
TwoLst=03 oLst=03
Lst=03 Lst=03
Lst=03 st=03
Lst=03 t=03

Which I think says, as mentioned above, that the addresses are
contiguous. So at least that is an easy visual and conceptual concept
to comprehend.
And to repeat what you put far more elegantly, more to see if I am
understanding it,
char *p  in the context of the declaration arr[m][n], is a "row"
and char **q, is a character?
 




 32 Posts in Topic:
Two dimensional array Question
mdh <mdeh@[EMAIL PROTE  2008-05-08 08:16:13 
Re: Two dimensional array Question
Joe Wright <joewwright  2008-05-08 19:15:37 
Re: Two dimensional array Question
"Default User"   2008-05-08 23:24:55 
Re: Two dimensional array Question
pete <pfiland@[EMAIL P  2008-05-08 21:03:36 
Re: Two dimensional array Question
"Default User"   2008-05-09 16:27:53 
Re: Two dimensional array Question
Ben Bacarisse <ben.use  2008-05-09 00:30:00 
Re: Two dimensional array Question
mdh <mdeh@[EMAIL PROTE  2008-05-08 18:39:27 
Re: Two dimensional array Question
Barry Schwarz <schwarz  2008-05-08 20:54:09 
Re: Two dimensional array Question
mdh <mdeh@[EMAIL PROTE  2008-05-09 06:18:51 
Re: Two dimensional array Question
mdh <mdeh@[EMAIL PROTE  2008-05-09 20:35:22 
Re: Two dimensional array Question
pete <pfiland@[EMAIL P  2008-05-10 07:09:06 
Re: Two dimensional array Question
Ben Bacarisse <ben.use  2008-05-10 12:42:22 
Re: Two dimensional array Question
pete <pfiland@[EMAIL P  2008-05-10 08:43:58 
Re: Two dimensional array Question
Joe Wright <joewwright  2008-05-10 09:26:20 
Re: Two dimensional array Question
Ben Bacarisse <ben.use  2008-05-10 14:53:55 
Re: Two dimensional array Question
pete <pfiland@[EMAIL P  2008-05-10 12:25:49 
Re: Two dimensional array Question
Ben Bacarisse <ben.use  2008-05-10 17:12:46 
Re: Two dimensional array Question
Ben Bacarisse <ben.use  2008-05-11 01:17:26 
Re: Two dimensional array Question
Barry Schwarz <schwarz  2008-05-11 04:17:57 
Re: Two dimensional array Question
mdh <mdeh@[EMAIL PROTE  2008-05-11 19:07:45 
Re: Two dimensional array Question
Richard Heathfield <rj  2008-05-12 03:16:04 
Re: Two dimensional array Question
Richard Heathfield <rj  2008-05-12 03:17:11 
Re: Two dimensional array Question
pete <pfiland@[EMAIL P  2008-05-12 07:18:50 
Re: Two dimensional array Question
"Default User"   2008-05-12 06:19:46 
Re: Two dimensional array Question
mdh <mdeh@[EMAIL PROTE  2008-05-12 21:12:17 
Re: Two dimensional array Question
Richard Heathfield <rj  2008-05-13 04:48:22 
Re: Two dimensional array Question
Chris Torek <nospam@[E  2008-05-13 16:38:01 
Re: Two dimensional array Question
Richard Heathfield <rj  2008-05-13 16:53:43 
Re: Two dimensional array Question
mdh <mdeh@[EMAIL PROTE  2008-05-12 21:13:55 
Re: Two dimensional array Question
pete <pfiland@[EMAIL P  2008-05-16 22:17:14 
Re: Two dimensional array Question
mdh <mdeh@[EMAIL PROTE  2008-05-12 22:26:08 
Re: Two dimensional array Question
Barry Schwarz <schwarz  2008-05-16 18:44:29 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Jul 26 4:00:21 CDT 2008.