The array you create is a local variable in the function getIt. When a function ends, local variables cease to exist. The memory that held them is available for the program to write over with anything it likes. You are thus returning a pointer to some place in memory that the program can (and will) write all over whenever it likes.