hi sir/ma’am how to convert a char to a string?
i got this error.
sketch_aug27a:90: error: invalid conversion from ‘char’ to ‘const char*’
sketch_aug27a:90: error: initializing argument 1 of ‘String::String(const char*)’
sketch_aug27a:93: error: invalid conversion from ‘char’ to ‘const char*’
sketch_aug27a:93: error: initializing argument 1 of ‘unsigned char String::equals(const char*) const’
char x;
n[20];
if((x, n)>0) // Number, Number length
{
String num=x;
if(num.equals("12345")){
Serial.print("Ok");
}
else{
Serial.print("Done");
}
The above code has many errors and I’m sure is not giving you the error messages you’ve listed.
-
What kind of array is n ? It’s not declared.
-
What’s this supposed to do … if((x, n)>0) … ?
-
You’re missing a brace, }. Where is it supposed to go ?
-
Is x really a type char or do you want it to be an array of characters, up to 20 characters long ? Is n = 20 ?
Post all your code and it’ll make more sense to us.
I tried using the String class (not strings) a couple of years ago and ran into nothing but weird problems. As I later found out the String class in ArduinoLand is not well implemented and the more experienced people I could find then said “Stay away from Strings”. That is, use strings instead. I have a guess as the what the OP was trying to do with the entirety of his code based upon the snippet he gave us. I believe it can be done simply, a number of ways, w/o Strings. But the OP needs to post his code and tell us what it is intended to do so all the guessing is not needed.