strncpy error

I am attempting to copy characters from a string using strncpy. I get the following error: error: cannot convert 'StringSumHelper' to 'const char*' for argument '2' to 'char* strncpy(char*, const char*, size_t)'

My sketch is as follows:

String GsmIn;
char GsmBytes;
char deviceID1[9];

void setup() {

void loop() {
  while (Serial.available()) {
        if (Serial.available() >0) {
        GsmBytes =;
        GsmIn += GsmBytes;}

    if (GsmIn.length() >0) {
          if (GsmIn.startsWith("SW")) {
//          strncpy( deviceID1, GsmIn+2, 8); // This is where I have an error
      Serial.println("Got SW"); // Debug to check if I got "SW"
    GsmIn=""; // Clear Buffer

Could anyone see the problem?

I am attempting to copy characters from a string using strncpy.

Incorrect. You are attempting to copy characters from a String using strncpy.

Are the String object and the classic C string (nul terminated array of characters) the same? Strcpy copy is for the latter.

Sorry, I don't understand. The string received is: SW0013A2004063D9BBD14

What they are telling you is that the strncpy() function operates on c-style strings (null-terminated arrays of chars), not String objects created with the String class. You could achieve the result you are after using a combination of String.substring() and String.toCharArray().

"C" strings and C++ "Strings" are two very very different things.

A "C" string is a pointer to an array of characters, terminated by a NULL character (ascii(0)).

A C++ "String" is a complete C++ object with many methods and properties etc.

There are ways of converting between the two, and you have to make sure that you are working with the right type of string for the function you are calling.