string to int

i have char arrey that get from serial and after thet split to 2 strings.
and i want to convert the 2 string to 2 int.

if (Serial.available() > 0){
    for (i = 0 ; i < 5 ; i++)
      readchar[i] = Serial. read();
  }

String stra = String (readchar[0] + readchar[1] + readchar[2]);
String strb = String (readchar[3] + readchar[4] + readchar[5]);


speedA = (int)stra;
speedB = (int)strb;

error:

error: invalid cast from type 'String' to type 'int'

i have char arrey that get from serial and after thet split to 2 strings.

No. After getting the char arrays, you split them into two Strings. Not the same thing at all.

speedA = (int)stra;

You can't cast a String to an int. The String class has a toInt() method...

tnx!
I do this:

speedA = stra.toInt();
speedB = strb.toInt();

I hope it will work.