I have a function that returns a pointer to an array, but its elements are not being printed as I expected.
Function fills up an array from user input and prints them (correctly!) in the console. After that I use the pointer to the same array that previous function returned, and I get some result like this:
You are returning a pointer to a local object. But that local object ceases to exist when the function terminates. The program/operating system is free to re-use that memory for some other purpose. Hence it may be overwritten with other data.