I am trying to compare a a received string in arduino to strings in a textfile to find a match, the text file contents are read perfectly just that the function will not accept the variable string.
it says cannot convert 'String' to constant char for argument and will not compile.
Please tell me some way i could compare the data in both variables.
how could i convert the string to a compatible type?
i use the string because the data is received in single characters anyway i could change this method to make str(n)cmp work?
while (keyboard.available()){
// read the next key
char p = keyboard.read();
if (p == 'j') {
stringComplete = true;
}
else {
inputString += p;
}
I'm not sure what you're trying to do, but give your code, you could code it as:
char p;
int index = 0;
while (keyboard.available()){
// read the next key
p = keyboard.read();
if (p == 'j') {
stringComplete = true;
break; // Message completed
} else {
buf[index++} = p;
}
}
buf[index] = '\0'; // Add if you want to treat it as a string.