Simple code is not working as expected

I'm trying to make "b" point to "a". If I do it inline, then everything is ok. But if inside function the "b" fails to point to "a".

void D(char* address, char* port)
{
	port = address;
}

void loop()
{
	char a[50] = "bla bla bla";
	char* b;
	//b = a;
	D(a,b);
	Serial.println(a);
	Serial.println(b);
	delay(1000);

Can anyone explain? Thanks ahead.

what is D(a,b) for?

It's just for testing purposes. It sould make "port" point to same as "address". So the programs prints two equal lines. But it doesn't.

port and address are local to the D() function. The values that they contain just happen to be addresses. Changing their value (as in the address value contained within the local variable) isn't going to extend beyond the function as you've seen. If you want to change the address of port, you need to pass a reference to it. This is isn't any different than passing any other numeric variable's value and expecting a change to the numeric value outside of the function(), you're just dealing with a char pointer data type.

Ok, seems I get it. I need to make function like this

void F(char* address, char** port)
{
   *port = address;
}

Thanks again.

How can I get value from char** A ?

**A[0] is not working.

Raptor5:
**A[0] is not working.

Each * is a derefence and the

 [0]

is also a deference, so that gives you 3 differences. What does your declaration of A look like now? Better yet, what does your updated code look like?

I want to split a string to Address and Port and return 1 if address starts with a number

bool isIPAddress(char** address, char** port)
{
	strsep(address,":");
	*port = *address;
	strsep(port, ":");
	*port = strsep(port, ";");
	return ((57 - **address[0]) >= 10);
}

void loop()
{
	char a[50] = "CONNECT:192.168.1.1:8000;";
	char* b;
	//b = a;
	char* c = a;
	Serial.println(isIPAddress(&c, &b));
	Serial.println(c);
	Serial.println(b);
	delay(1000);
}

Raptor5:
I want to split a string to Address and Port and return 1 if address starts with a number

bool isIPAddress(char** address, char** port)

{
strsep(address,":");
*port = *address;
strsep(port, ":");
*port = strsep(port, ";");
return ((57 - **address[0]) >= 10);
}

void loop()
{
char a[50] = "CONNECT:192.168.1.1:8000;";
char* b;
//b = a;
char* c = a;
Serial.println(isIPAddress(&c, &b));
Serial.println(c);
Serial.println(b);
delay(1000);
}

One too many deferences on address.

Seems strtok() would be more appropriate here. First call gives you "CHANNEL" second gives you the IP and the third gives you the port.
If you don't want to destroy your original string, then you can make a copy, and pass a reference for the port and the address and assign your result to the results of strtok() to them. Just off the top of my head.