arduino c string split by delimiter
/* Original code on Stackoverflow
https://stackoverflow.com/questions/29671455/how-to-split-a-string-using-a-specific-delimiter-in-arduino
Example :
String str = "1,2,3";
String part01 = getValue(str,';',0); // get 1
String part02 = getValue(str,';',1); // get 2
String part03 = getValue(str,';',2); // get 3
String part03 = getValue(str,';',4); // get empty string
Documented by issa loubani, your average programmer :P */
// Happy coding O.O
String getValue(String data, char separator, int index)
{
int found = 0;
int strIndex[] = {0, -1};
int maxIndex = data.length()-1;
for(int i=0; i<=maxIndex && found<=index; i++){
if(data.charAt(i)==separator || i==maxIndex){
found++;
strIndex[0] = strIndex[1]+1;
strIndex[1] = (i == maxIndex) ? i+1 : i;
}
}
return found>index ? data.substring(strIndex[0], strIndex[1]) : "";
}
Also in C:
- rakshabandhan 2020
- With a suitable example, explain increment, decrement and compound assignment operators
- pointer parameter where to put the asterix in C?
- fibonacci sequence single recursive call
- hostbuilder add environment variables
- read a binary file c
- resto de division recursiva
- remove element from np array
- mediawiki upload size
- excel cell blank or zero
- BlockChain in c
- vue cdn
- fgets in c
- With which of the following can you run code without provisioning or managing servers and pay only for the compute time consumed (there is no charge when the code is not running)?
- arduino c string split by delimiter
- set firestore merge
- obby übersetzung
- error: ‘cout’ was not declared in this scope
- c bool
- is it possible to access argv in function
- how to make a debug in c
- declaration in c
- multiplication in c
- curl authorization header