473,394 Members | 2,020 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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

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
6 1742
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

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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Alex Vinokur | last post by:
Various forms of argument passing ================================= C/C++ Performance Tests ======================= Using C/C++ Program Perfometer...
6
by: Gil | last post by:
Can anyone see why I'm getting an error with the following code : void NewData::store(NewDataStruct nd, unsigned long& NewDataID) { OtherData.store(nd, NewDataID); // error in this line //...
44
by: Steven T. Hatton | last post by:
This may seem like such a simple question, I should be embarrassed to ask it. The FAQ says an object is "A region of storage with associated semantics." OK, what exactly is meant by "associated...
1
by: Mark Dicken | last post by:
Hi All I have found the following Microsoft Technet 'Q' Article :- Q210368 -ACC2000: How to Pass an Array as an Argument to a Procedure (I've also copied and pasted the whole contents into...
0
by: erktek | last post by:
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) { ...... }
5
by: Roy Smith | last post by:
I've got some legacy code I'm maintaining. There's a method declared in the class.h file like this: void foo(unsigned priority); and it's implemented as: void myClass::foo (unsigned /*...
3
by: assgar | last post by:
Hi I thought I had resolved this problem but I am intermittently the receving the warnings below. This code consist of a 1) HTML form, 2) a display function on the HTML form and 3) a...
7
by: bowlderster | last post by:
Hello,all. I want to get the array size in a function, and the array is an argument of the function. I try the following code. /*************************************** */ #include<stdio.h>...
17
by: Klaas Vantournhout | last post by:
Hi all, I was wondering if it is possible if you can check in a function if one of the arguments is temporary. What I mean is the following. A is a class, foo is a function returning a class...
5
by: =?Utf-8?B?RGF2aWQgTGV2aW5l?= | last post by:
This is really more of a "why was C# designed this way?" type of question. Hope this is the write forum for this question. Given the following : class Base1 { public int i; } struct Base2...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.