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() {
Serial.begin(9600);
}
void loop() {
while (Serial.available()) {
delay(10);
if (Serial.available() >0) {
GsmBytes = Serial.read();
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?