James [on his mailserver] wrote:
> would this work:
>
> int thing[0], *ptr = thing;
> int in;
>
> ...
> printf ("Enter a number > 0:");
> scanf ("%d", &in);
>
> realloc (ptr, in);
> ...
No, it wouldn't. The first argument to realloc() should either be
NULL, or the value returned by a prior call to malloc() (or realloc,
calloc, strdup etc).
If the dynamic array has a long lifespan (i.e. it is used outside of
the function which initialises it), then use malloc() to allocate the
array. If the array is only used within a single function, you can use
alloca() instead.
--
Glynn Clements <[EMAIL PROTECTED]>