String to int

How I can convert String object to integer? Thanks.

I use the below when sending servo positions to the arduino as strings, which are captured as the string "readstring"

Serial.println(readstring);  //so you can see the captured string 
    char carray[readstring.length() + 1]; //determine size of the array
    readstring.toCharArray(carray, sizeof(carray)); //put readstringinto an array
    int n = atoi(carray); //convert the array into an Integer

Thank you so much :)