Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Formal Argument for int Array[x][y]?

Reply
Thread Tools

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

 
 
erktek@gmail.com
Guest
Posts: n/a
 
      11-18-2005
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?

 
Reply With Quote
 
 
 
 
Skarmander
Guest
Posts: n/a
 
      11-18-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) 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.
 
Reply With Quote
 
 
 
 
haroon
Guest
Posts: n/a
 
      11-18-2005

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?

 
Reply With Quote
 
pete
Guest
Posts: n/a
 
      11-18-2005
(E-Mail Removed) 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
 
Reply With Quote
 
Skarmander
Guest
Posts: n/a
 
      11-18-2005
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 ((E-Mail Removed)) 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.
 
Reply With Quote
 
Eric Sosman
Guest
Posts: n/a
 
      11-18-2005
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
(E-Mail Removed)lid
 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      11-18-2005
Skarmander <(E-Mail Removed)> 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 ((E-Mail Removed)) 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) (E-Mail Removed) <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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference between int i, j; and int i; int j; arun C Programming 8 07-31-2006 05:11 AM
Formal Argument for int Array[x][y]? erktek@gmail.com C Programming 0 11-18-2005 09:52 AM
Error : Formal argument requires an lvalue Gil C++ 6 01-31-2004 10:39 AM
int main(int argc, char *argv[] ) vs int main(int argc, char **argv ) Hal Styli C Programming 14 01-20-2004 10:00 PM
dirty stuff: f(int,int) cast to f(struct{int,int}) Schnoffos C Programming 2 06-27-2003 03:13 AM



Advertisments