I know that arrays with lengths determined at runtime are possible by declaring the array normally:
char buf[len];
and I know that I can declare an array as a compound litral and assign it to a pointer midway:
char *buf;
....
buf = (char[5]) {0};
However, combining the two doesn't work (is not allowed by the standard).
My question is: Is there any way to achieve the effect of of the following code? (note len
)
char *buf;
....
buf = (char[len]) {0};
Thank you.
memset
not an option ? – Hortensiahorteralloca
could be used... – Bartram