By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,498 Members | 1,783 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,498 IT Pros & Developers. It's quick & easy.

Formal Argument for int Array[x][y]?

P: n/a
Hi!
It is clear that when we try to pass a one dimentional array to a
function
we use int* such as
void display(int *LocalAarray)
{
......
}

int main(void)
{
int MainArray[3] = {1, 2, 3};

display(MainArray);
return 0;
}
name of the array is automaticly casted to (int*)
but what is the case I want to use two dimensional array ?
int main(void)
{
int MainArray[2][3] = {{1, 2, 3},
{4,5,6}};

display(MainArray);

return 0;
}

what should be the formal parameter of display function?
void display(int** Local Array) ? <-- Is it true?

Nov 18 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
er****@gmail.com wrote:
Hi!
It is clear that when we try to pass a one dimentional array to a
function
we use int* such as
void display(int *LocalAarray)
{
......
}

int main(void)
{
int MainArray[3] = {1, 2, 3};

display(MainArray);
return 0;
}
name of the array is automaticly casted to (int*)
but what is the case I want to use two dimensional array ?
int main(void)
{
int MainArray[2][3] = {{1, 2, 3},
{4,5,6}};

display(MainArray);

return 0;
}

what should be the formal parameter of display function?
void display(int** Local Array) ? <-- Is it true?

That's a good question, which is why the answer is in the FAQ:
http://www.eskimo.com/~scs/C-faq/q6.18.html

Read the rest of it while you're there, it's good stuff.

S.
Nov 18 '05 #2

P: n/a

Skarmander wrote:
[snip]
That's a good question, which is why the answer is in the FAQ:
http://www.eskimo.com/~scs/C-faq/q6.18.html


who is responsible for this FAQ and what is the frequency of update?

Nov 18 '05 #3

P: n/a
er****@gmail.com wrote:

Hi!
It is clear that when we try to pass a one dimentional array to a
function
we use int* such as

void display(int *LocalAarray)
{
......
}

int main(void)
{
int MainArray[3] = {1, 2, 3};

display(MainArray);
return 0;
}
name of the array is automaticly casted
"converted" is a more better word to use than "casted", there.
to (int*)
but what is the case I want to use two dimensional array ?
int main(void)
{
int MainArray[2][3] = {{1, 2, 3},
{4,5,6}};

display(MainArray);

return 0;
}

what should be the formal parameter of display function?
void display(int** Local Array) ? <-- Is it true?


void display(int (*Local_Array)[3]);

--
pete
Nov 18 '05 #4

P: n/a
haroon wrote:
Skarmander wrote:
[snip]

That's a good question, which is why the answer is in the FAQ:
http://www.eskimo.com/~scs/C-faq/q6.18.html

who is responsible for this FAQ and what is the frequency of update?

Steve Summit (sc*@eskimo.com) is the one responsible, and the last
update was on July 3, 2004 (this is the version posted monthly to the ng
and available through anonymous FTP at rtfm.mit.edu). Search Usenet
archives like Google's for the skinny.

S.
Nov 18 '05 #5

P: n/a
haroon wrote:
Skarmander wrote:
[snip]

That's a good question, which is why the answer is in the FAQ:
http://www.eskimo.com/~scs/C-faq/q6.18.html

who is responsible for this FAQ and what is the frequency of update?


Read the FAQ.

True, it only answers one of your questions completely.
But it gives a pretty good hint about the other, and I don't
think you deserve a more complete answer until you've given
some tiny indication that you're willing to expend two or
three of your own mouse clicks in pursuit of knowledge. You've
been served a URL on a silver platter; can you eat it yourself,
or do you need servants to lift each morsel to your lips, or
maybe even chew it for you?

--
Eric Sosman
es*****@acm-dot-org.invalid
Nov 18 '05 #6

P: n/a
Skarmander <in*****@dontmailme.com> writes:
haroon wrote:
Skarmander wrote:
[snip]
That's a good question, which is why the answer is in the FAQ:
http://www.eskimo.com/~scs/C-faq/q6.18.html

who is responsible for this FAQ and what is the frequency of update?

Steve Summit (sc*@eskimo.com) is the one responsible, and the last
update was on July 3, 2004 (this is the version posted monthly to the
ng and available through anonymous FTP at rtfm.mit.edu). Search Usenet
archives like Google's for the skinny.


A more up-to-date version, in gzipped text format, is at
<ftp://ftp.eskimo.com/u/s/scs/C-faq/faq.gz>. The HTML pages don't
appear to have been updated since 1995.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 18 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.