I have esp8266 with webserver. Now I want changr the IP address from web.
How to convert: String strIP = "192.168.4.1" to IPAddress ip(192, 168, 4, 1)
Thank.
Something along these lines should work.
int Parts[4] = {0,0,0,0};
int Part = 0;
for ( int i=0; i<strIP.length(); i++ )
{
char c = strIP[i];
if ( c == '.' )
{
Part++;
continue;
}
Parts[Part] *= 10;
Parts[Part] += c - '0';
}
IPAddress ip( Parts[0], Parts[1], Parts[2], Parts[3] );
Stackoverflow would be a better place to ask this sort of question, it's not an issue :)
IPAddress addr;
if (addr.fromString(strIP)) {
// it was a valid address, do something with it
}
@hoacvxd not the right place to ask these questions.
Closing due to off-topic, see #3655 .
Most helpful comment