Re: Some doubts on variable-length array
- From: "lovecreatesbeauty" <lovecreatesbeauty@xxxxxxxxx>
- Date: 31 Mar 2006 09:12:25 -0800
Ben Bacarisse wrote:
foo(2, 2, tab); /* A. don't understand */
This calls "lies" to foo telling it that the array is 2x2 so foo sees it
as if it were "int tab[2][2] = {{0, 1}, {2, 3}};". Element [1][1] is 3
and this is what is printed.
I know it before that functions regard an array argument same as a
pointer. So how can the layout/dimension of an actual array argument be
known inside the function body? Are new meanings/semantics given to
array arguments when they are variable-length array?
foo(3, 3, tab); /* A. don't understand */
This call does not "lie". So inside foo it is seen as it was defined and
element [1][1] is the number 4.
The original array is: /* int tab[9] = {0, 1, 2, 3, 4, 5, 6, 7, 8}; */
, if it is used instead, then foo(3, 3, tab); lies again, right?
I can understand the original sample code in your way, but get more
anxious on how a function knows the layout/dimension of actual array
arguments.
.
- Follow-Ups:
- Re: Some doubts on variable-length array
- From: Ben Bacarisse
- Re: Some doubts on variable-length array
- References:
- Some doubts on variable-length array
- From: lovecreatesbeauty
- Re: Some doubts on variable-length array
- From: lovecreatesbeauty
- Re: Some doubts on variable-length array
- From: Ben Bacarisse
- Some doubts on variable-length array
- Prev by Date: What will happen if main called in side main function?
- Next by Date: Significance of trigraph in C preprocessor
- Previous by thread: Re: Some doubts on variable-length array
- Next by thread: Re: Some doubts on variable-length array
- Index(es):
Relevant Pages
|