In general, there is a code. The variable is passed to the need_size variable. Next, create a string of size need_size. And then the snag. As far as I know, according to the C standard, the size of static arrays should be known at the compilation stage. However, gcc versions 3 and 4 compile this miracle without complaints (even without Vorning), visual c - immediately throws three errors, one of them is the expected constant expression, which looks logical. The code compiled by gcc is working correctly. Tell me, does gcc replace this code with a malloc call? Or is it the magic of Hogwarts and nothing stands out and with this use there is a risk to go beyond memory?
char* string_space(char *str, int need_size) { char stringspace[need_size]; ... }