0
How can I concatenate two or more strings using the language C
with Arduino.
I’m following several examples I’ve found around, but it always makes a mistake. "Conversion from 'unsigned char' to 'String' is ambiguous"
I’m using the .concat()
void VuetifyDateTime(int hours,int minutes)
{
String hourSt = String(hours);
String minutesSt = String(minutes);
String dateTime = hourSt.concat(minutesSt);
TM1637(dateTime.toInt());
This String type is from a library or is a typedef of yours?
– aviana
It’s from Arduino itself. String class
– adriano
hourSt.concat(String(minutes));
should remove ambiguity. According to the reference, this function accepts String type parameters. https://www.arduino.cc/reference/pt/language/variables/data-types/string/functions/concat/– aviana
It worked. Want to post as response?
– adriano
No need, it was just a type casting problem and this is trivial. I believe the type
String
have some operator who does the automatic conversion tounsigned char
and as Concat accepts many different types, the compiler gets confused by the ambiguity.std::string
is more reliable.– aviana