Hi quick question, say i allocate some memory within a function call, but before the function exits and the pointer to the allocate memory is destroyed, i pass the address of the pointer to a variable declared locally within my program. Will this effect the running of the program in anyway? In other words, would i have any problems in using the local pointer within the main program. For example, this is a program just to illustrate what i mean:
Thanks for your time.Code:int *Test(void); int main(void) { int *LocalPtr = NULL; LocalPtr = Test(); for(int i=0; i < 99; i++) cout << LocalPtr[i]; //can i still access the array like this? delete []LocalPtr; //can i still delete the array like this? return 0; } int *Test(void) { int *FuncPtr = new int [100]; return FuncPtr; }