Hey guys,
can someone tell me why I get this error message?
Code:
String split(String s, char parser, int index) {
String rs="";
int parserIndex = index;
int parserCnt=0;
int rFromIndex=0, rToIndex=-1;
while (index >= parserCnt) {
rFromIndex = rToIndex+1;
rToIndex = s.indexOf(parser,rFromIndex);
if (index == parserCnt) {
if (rToIndex == 0 || rToIndex == -1) return "";
return s.substring(rFromIndex,rToIndex);
} else parserCnt++;
}
return rs;
}
void setup() {
// put your setup code here, to run once:
String myStr = "/my/new/string";
char delimiter = "/";
String myStrPrt = split(myStr, delimiter, 1);
}
void loop() {
// put your main code here, to run repeatedly:
}
Error message:
C:\Users\alve89\AppData\Local\Temp\arduino_modified_sketch_966093\sketch_apr16a.ino: In function 'void setup()':
sketch_apr16a:20:20: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
20 | char delimiter = "/"; // doesn't work with an "a" neither
I thought it might be issued by the slash because it's not a char but it still doesn't work with an a.
Thanks in advance!