How can I convert Arduino String to C string type? I got a String which as I understand is an Arduino object, and got some C++ code:

#include &lt;Wire.h&gt; 
#include &lt;LiquidCrystal_I2C.h&gt;
#include &lt;string.h&gt;

LiquidCrystal_I2C lcd(0x20,16,2); 

boolean borrar = false;
String IP;

void setup()
{
  lcd.init();
  lcd.backlight();
  pinMode(13,OUTPUT);
  Serial.begin(9600);
  Serial1.begin(9600);

}

void loop() {

  while (Serial1.available()) { 

    char caracter = Serial1.read(); //Comprobamos el caracter 

    switch(caracter) {

    default:
                if (borrar) { 
                              IP = ""; 
                              lcd.clear();
                }

                lcd.print(caracter);
                delay(125);
                borrar = false;

                IP.concat(caracter);
                break;  

    case '\r':                
    case 0x0F:
    case 0x0A:  

                String res = "";
                borrar = true;
                int num= atoi(IP.c_str());
                if (num &lt; 127) 
                  res="Clase A";
                if (num == 127) 
                  res="Direccion reservada";
                if (num &gt; 127 &amp;&amp; num &lt; 192)
                  res="Clase B ";
                if (num &gt;= 192 &amp;&amp; num &lt; 224)
                  res="Clase C ";
                if (num &gt;= 224 &amp;&amp; num &lt; 240)
                  res="Clase D ";
                if (num &gt;= 240 &amp;&amp; num &lt; 255)
                  res="Clase E ";
                break;  

  } //fin switch

}//serial disponible


}//fin programa


However, this won't compile because of this line:

int num= atoi(IP.c_str())


As IP is a String and such method works for string. How can I make it compatible (convert it)?
Try

unsigned char z[100];
IP.getBytes(z, 100);
z[IP.length()] = 0;
int n = atoi(z);


To retrieve bytes inside the string. This assumes IP string's length is shorter than 100.