user50292: I am using the WiFi library and trying to store the IP address in a character buffer so that I can print it out to an lcd that only accepts character buffers. My code for doing this:
 char * IPAD = new char[40
 IPAddress ip = WiFi.localIP();
 Serial.println(ip);
 char * bufIP = new char[40]();
 sprintf(bufIP, "%s", inet_ntop(ip));
 lcd.string(ip);

But when I compile this I get the error:
"inet_ntop' was not declared in this scope"

Help?

user4143: An IPAddress is a class. You can't use it like a number (although in certain circumstances you can assign it to a uint32_t and it gives you the numeric representation).
Also, the inet_* functions are only really relevant on a POSIX system with a full network stack - i.e., a computer, not a little Arduino without a proper networking stack.
You can, though, easily access the individual bytes of the IP address through the [] operator and place them into a char array with the right format:
sprintf(bufIP, "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);


50292: <p>I am using the WiFi library and trying to store the IP address in a character buffer so that I can print it out to an lcd that only accepts character buffers. My code for doing this:</p>

<pre><code> char * IPAD = new char[40
 IPAddress ip = WiFi.localIP();
 Serial.println(ip);
 char * bufIP = new char[40]();
 sprintf(bufIP, "%s", inet_ntop(ip));
 lcd.string(ip);
</code></pre>

<p>But when I compile this I get the error:</p>

<pre><code>"inet_ntop' was not declared in this scope"
</code></pre>

<p>Help?</p>
 4143: <p>An <code>IPAddress</code> is a class. You can't use it like a number (although in certain circumstances you can assign it to a <code>uint32_t</code> and it gives you the numeric representation).</p>

<p>Also, the <code>inet_*</code> functions are only really relevant on a POSIX system with a full network stack - i.e., a computer, not a little Arduino without a proper networking stack.</p>

<p>You can, though, easily access the individual bytes of the IP address through the <code>[]</code> operator and place them into a char array with the right format:</p>

<pre><code>sprintf(bufIP, "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
</code></pre>
