From: Luciano Moreira - igLnx <lucianolnx@ig.com.br>
To: Ankit Jain <ankitjain1580@yahoo.com>
Cc: linux prg <linux-c-programming@vger.kernel.org>
Subject: Re: pass 2 D array in C
Date: Thu, 14 Oct 2004 10:08:46 -0300 [thread overview]
Message-ID: <416E7A5E.6090603@ig.com.br> (raw)
In-Reply-To: <20041014112615.91429.qmail@web52901.mail.yahoo.com>
The following sample was coded now, without compiling, then It can have
some mistakes for compiler.
But I think that it ll can be good for your analyse. Using this sample,
you can allocate any kind of array, like as 3D, 4D, 5D, and so on.
Luciano
-----------------------------------------------------------------------------------------
main()
{
int THE_LENGTH = 200; /* Numbers of itens of array */
long **p2DArray;
pp2DArray = new long[THE_LENGTH];
/* for C-ANSI: pp2DArray = malloc(sizeof(long) * THE_LENGTH); */
fill_array(pp2dArray, THE_LENGTH);
dump_array(pp2dArray, THE_LENGTH);
delete pp2DArray;
/* forC-ANSI: free(pp2DArray); */
}
fill_array(char *pp, int nLength)
{
int ct;
for ct(=0; ct<nLength; ct++) {
ppArray[ct] = (long) rand();
}
}
dump_array(char *pp, int nLength)
{
int ct;
for (ct=0; ct<nLength; ct++) {
printf("Item %d: %ld\n", ct, ppArray[ct]);
}
}
-----------------------------------------------------------------------------------------
Ankit Jain escreveu:
>its a simple question...
>
>how to pass a 2 D array address in C
>
>is there any way by **pointer?
>
>thanks
>
>ankit
>
>________________________________________________________________________
>Yahoo! Messenger - Communicate instantly..."Ping"
>your friends today! Download Messenger Now
>http://uk.messenger.yahoo.com/download/index.html
>-
>To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at http://vger.kernel.org/majordomo-info.html
>
>
>
>
next prev parent reply other threads:[~2004-10-14 13:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-10-14 11:26 pass 2 D array in C Ankit Jain
2004-10-14 13:08 ` Luciano Moreira - igLnx [this message]
2004-10-14 13:13 ` Luciano Moreira - igLnx
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=416E7A5E.6090603@ig.com.br \
--to=lucianolnx@ig.com.br \
--cc=ankitjain1580@yahoo.com \
--cc=linux-c-programming@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).