WD Interview Question

what is wrong with a code in C, and how to improve it

Interview Answer

Anonymous

Feb 18, 2021

the problem was the function returned a pointer to an array created into the function itself, which will come back empty (because all the function's variables are deleted when it's finished), and the array was only in size of 100. The solution is to define a malloc into the main and send a pointer to the function to fill.