Pages: 1 [2]   Go Down
Author Topic: How can I simplify this simple code?  (Read 1020 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Karma: 0
Posts: 27
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks guys!

RadarProject - Arduino Autopilot for RC

Offline Offline
Shannon Member
Karma: 223
Posts: 12630
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Can someone please direct me to an article (Or give me an explanation) on why using String variables are usually bad in C++/Arduino?

There is a specific problem with the Arduino String class because it exposes a bug in the Arduino memory management. But using strings to represent numbers is generally a bad idea anyway because you then need to parse the string to get the number each time you need to use it. This slows your code down and introduces potential problems in any situation where the string might not contain a valid number. Best to treat numbers as numbers - if you're given a string, parse it to a number once and use the number from then on - if you need to output a string, format the number as a string at the point you need to output it.

I only provide help via the forum - please do not contact me for private consultancy.

Pages: 1 [2]   Go Up
Jump to: