I have a project and i need to convert string (contain numbers and letters) to array
String name = "s111, s222, bbbb,cccc ";
and i want
array[0] = s111;
array[1] = s222;
array[2] = bbbb;
array[3] = cccc;
here is the code :
String name = "s111, s222, bbbb,cccc ";
int array[50];
int r=0,t=0;
for(int i=0;i<name.length();i++){
if(name.charAt(i) == ','){
array[t] = name.substring(r,i);
r = (i+1);
t++;
}
for(int k=0 ;k<=t ;k++){
Serial.println(array[k]);
}
When I compile I get just zeros like :
array[0] = 0;
array[1] = 0;
array[2] = 0;
array[3] = 0;
it wont work
, it uselessarray[0] = s111;
”: this doesn't make sense.array
is an array ofint
s, and “s111” is not anint
.