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.