Hi everyone, i was trying to return a pointer to a character array in my c++ program and got a warning....i submitted the program with a warning on the online judge it gives wrong answer.....as soon as i make the array global i get the solution accepted....wats the trouble returning the pointer to a character array??
How did you create the array? You can't return a pointer to a local array, such as
T array[10];
Or rather, you can, but the pointer will be invalid.
You can only return valid pointers to dynamic arrays:
T *array=new T[10];