vaxman
September 30, 2017, 4:31pm
1
Hello,
I have two strings as follows:
String abc ="123456789"; //this string always hold numbers
String def; //this one will be converted later to INT
and would like to extract the 1'st 5 characters from string abc and put it in string def for further processing.
So, substring is out of the question because there is no special character I can use for a reference. And can't find a suitable command to do it.
Any help is appreciated.
pert
September 30, 2017, 4:40pm
2
This will be helpful to you:
The Arduino programming language Reference, organized into Functions, Variable and Constant, and Structure keywords.
Of course you should just use char arrays instead, which can be manipulated in the same way:
https://www.arduino.cc/en/Reference/String
http://www.cplusplus.com/reference/cstdlib/atoi/
Why is substring out of the question?
Pete
Robin2
September 30, 2017, 6:18pm
5
It is not a good idea to use the String (capital S) class on an Arduino as it can cause memory corruption in the small memory on an Arduino. Just use cstrings - char arrays terminated with 0.
...R