Is there a stackalloc function implemented in C that allows you to allocate a variable length array on the stack, like stackalloc in C#?
There's alloca
but it's non-standard. Moreover, since C99 there's a feature called "Variable Length Arrays".
int n;
scanf("%d", &n);
int v[n]; /* Will fail badly if n is large. */
Used sparingly and with small values VLAs can be quite nice.
alloca
works a little like that, but you need to be very careful using it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With