Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

How so? Do you mind giving an example of a printf like function that needs variable length arrays?


I wouldn't call it a "need", more like "occasionally desirable". The short version is that it's a convenient method of letting the compiler handle resource management when you have a variable number of values and sufficient stack space. As others pointed out, it's particularly handy for multi-dimensional arrays.

There are also some possible applications here: http://gustedt.wordpress.com/2011/01/13/vla-as-function-argu...

In fairness, I've used them only rarely, but those few times I've used them have saved me a bit of grief.

I could easily live without them if required...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: