"Kris Wempa" <calmincents(NO_SPAM)@yahoo.com> wrote in message
Sorry,
So it looks like you're trying to define an array of
unspecified size (what you called 'zero based').
Correct terminology is important. You probably
see that now, from the replies you've got so far.
void foo(int a[]); /*a[] possible*/
Here, 'a' is a function parameter. While it *looks* like
an array, it is not, it's a pointer. [1]
(An array cannot be passed to or returned from functions,
only a pointer to one of its elements can (typically the
first). The [] form is just an alternate syntax.
int main(void)
{
unsigned int y[]; /*y[] *not possible*/
No, not possible. Your definition says 'make me an array'
An array is a sequence of *one or more* contigous objects of
the same type. But you did not tell it how many. How can
the compiler make the array?
How many 'unsigned ints'
do you want/need? Just say so, e.g.
unsigned int y[10]; /* array of ten unsigned ints */
May I ask which textbook(s) you're learning from?
[1]
void foo(int a[]);
vs.
void foo(int *a);
Both of these declare that the parame ter'a' is of type
'pointer to int' (int*). Some prefer the first form, others
the latter, a case can be made for each.
When such a function is intended to operate upon an
array, some say that the a[] form conveys this intent,
and that the *a form should only be used when passing
the address of a single object.
Others say that the a[] only unnecessarily 'disguises'
the fact that the parameter is really a pointer.
This seems to me to be a religious issue which I don't
care to debate. I use the *a form, simply because it's
a pointer. But that's just *my* style, it's neither right
nor wrong (unless of course it violates coding standards
to which I've agreed to ahere).
HTH,
-Mike