Declaring array. Is this ok ?

Henry Spencer henry at zoo.toronto.edu
Wed Nov 14 06:38:13 AEST 1990


In article <APS.90Nov12074527 at kaarne.tut.fi> aps at tut.fi (Suntioinen Ari) writes:
>I was wondering if following is legal in (ANSI) C:
>int somefunc(int i)
>{
>	int  array[i]; /* Can I use i here ? */
> ...
>int i;
>...
>{
>	int  array[i]; /* How about here ? */

No.  Array dimensions must be constant expressions, known at compile time.

>Gcc seems to accept both.

Gcc compiles an interesting language which is not ANSI C.
-- 
"I don't *want* to be normal!"         | Henry Spencer at U of Toronto Zoology
"Not to worry."                        |  henry at zoo.toronto.edu   utzoo!henry



More information about the Comp.lang.c mailing list