Sprint or strcpy in arduino ?

I have a function that gets a pointer , and it should then change that pointer to a new one, so

void function (char *pointer)
{

char data[40];
// some calculations

//send back respond
strcpy(pointer,data);

}

I have read here that strcpy is a bad practice and that there are replacements(in Arduino? ) :

What is the right command to change that pointer argument safely ?

thanks .

I have a function that gets a pointer

You have a function that takes a pointer...

and it should then change that pointer to a new one

That is not what that code does. It changes the data at the location the pointer points to. That is perfectly valid as long as you know how much memory is pointed to, and you are certain not to try to write more data there than can fit.

I have read here that strcpy is a bad practice

Because strcpy() relies on you knowing what you are doing. strncpy() is usually a better choice, since you need to explicitly define the maximum amount of data to copy.

I have read that page at stackoverflow.com, and I agree with 'Lundin' who writes "This answer is full of bad advice and misinformation".

The best function for the pointer depends on the code and the type of data. Is it a string ? Is it fixed length ? Do you want to keep the data unchanged when an error occurs ? And so on.

PaulS's posting at 1:02 PM was right on the mark.

BenStlr posted the question "What is the right command to change that pointer argument safely ?" and posted code that doesn't change the pointer argument at all. I am confused.

PaulS's posting at 1:02 PM was right on the mark.

Agreed.

strncpy() is usually a better choice

better, but it doesn't do what most people think. (it zero-fills the whole string, rather than 0-terminating.)
"strlcpy" is good. The stackoverflow discussion is not particularly helpful, IMO.