I'm trying to create a variable, char x[], inside a method and then return it.
I'm getting: address of stack memory associated with local variable 'x' returned
This is because the memory allocated to x will be freed when the method finishes execution. To prevent this, I could declare the variable as static, static char x[] but then
I'm getting: variable length array declaration cannot have 'static' storage duration
Because I'm using another variable's length when declaring my x array.
I'm new to C, can someone tell me what is the best practice here? What should I do?