[LC++]problem about defining an array

Vincent Penquerc'h vincent at qubesoft.com
Fri Jul 27 20:27:10 UTC 2001


> It wont work (unless C99 has changed it). Do something like this instead:
> 
> void writee(double h, double level,....)
> {
> 	double *strr = new double[level];
> 	...
> 	delete[] strr;
> }

You might also need to explicitely cast it to an integral
type (int, unsigned int, etc), unless the compiler does it
for you. Also, GCC has an extension which allows variable
length arrays (but then it is non portable).
I also think (but there I've never seen or done it) that
C99 now allows variable size arrays, though probably with
another syntax.

-- 
Lyrian 




More information about the tuxCPProgramming mailing list