Feature request / core lib / Serial.print

It would be great if Serial.print and its cousins accepted an argument of type String. String is a special Arduino class, and we work with it often, and thus we sometimes write code like


This compiles and then crashes during runtime. It would be nice if either a) it didn't compile, or b) it ran in the obvious way (using the object's c_str() method).

Thanks for your time!

Hi @alan9988. They do:

You can see a demonstration of it in the official documentation here:

Thousands of people print String objects every day without problems, so this is definitely unusual. That said, there are definitely ways you can get into trouble using the String class, and in fact some here recommend against its use.

We can probably help you out with your problem, but we'll need you to provide a minimal demonstration sketch we can use to reproduce the issue. We also need to know which board you are using.

Seems I was marvelously confused. Thanks for the quick reply, I'll show myself out... :grimacing:

You're welcome. I'm glad if I was able to be of assistance. Enjoy!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.