Re: How to get a point of array?
- From: "John Carson" <jcarson_n_o_sp_am_@xxxxxxxxxxxxxxx>
- Date: Mon, 17 Oct 2005 00:20:51 +1000
"zhanglr" <zhanglr@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:0BB60001-5223-4F6A-9DA2-91D209B2F30D@xxxxxxxxxxxxx
Hi,
Is it possible to get a point of array?
both of "char[][]* pararch = &ararch;" and "char*** pppararch = &ararch;" failed. Of course, I can do it like "char*** pppararch = (char***)&ararch;" But I want to know whether there is any decent or official way to do it.
----------------------------------------------------------------------- char ararch[3][3]; // char[][]* pararch = &ararch; // char*** pppararch = &ararch;
Best Regards, ZHANG Liren
If you really want a pointer to the 3 by 3 array named ararch, then you can do it with:
char (*pararch)[3][3] = &ararch;
I am not sure if this is really what you want. Using the above code, to get the equivalent of
ararch[i][j]
you will need to use
(*pararch)[i][j]
Perhaps what you really want is a pointer to the first row of the array:
char (*pararch)[3] = &ararch[0];
In this case, the equivalent of
ararch[i][j]
is the simpler
pararch[i][j]
Note: the use of 3 as both the row and column dimension may make the foregoing less clear than it might be. Suppose we had:
char ararch[3][4];
Then you would need:
char (*pararch)[4] = &ararch[0];
i.e., you use the second dimension.
--
John Carson
.
- Follow-Ups:
- Re: How to get a point of array?
- From: zhanglr
- Re: How to get a point of array?
- Prev by Date: Re: C++ vs. .net
- Next by Date: Re: Getting Certified
- Previous by thread: Re: C++ vs. .net
- Next by thread: Re: How to get a point of array?
- Index(es):
Relevant Pages
|