You are returning a pointer to a local variable in func00() that is destroyed when the function exits. If you must do it as you are, you'll need to dynamically allocate memory inside func00() and return a pointer to that. Though you'll then need to delete[] outside of where it was created which is not a good idea IMO.