How to declare a variable length array in Visual Studio C89 after another code

I understand that in VS all variables must be declared at the top of the block, but if I want a VLA, i.e. if I wanted to do something like this:

int result = runalgorithm(); 

int vla[result];

the above code is invalid because it vlamust be declared at the top. What is a good solution for this besides creating an arbitrarily large array?

+4
source share
2 answers

You can not. VLA is supported in C99later standards. (Support is required in C99, it is optional in C11.) C89Does not have a VLA concept or support for it.

. malloc() .

, (), free() , , .

+1

MSVC VLA. MSVC , C ( , VS 2013).

0

All Articles