Hi,
a simple program and also a simple problem, but I can not find a solution.
someone has a tip for me?
char text[] = "Value1, 1000, Value2,100,Value3,1.414,end";
void setup()
{
Serial.begin(9600);
}
void loop(){
char *p = text;
char *str;
while ((str = strtok_r(p, ",", &p)) != NULL) // delimiter is comma
{ Serial.println(str);
delay(500);
}
}
The output ist not as expected:
Value1
1000
Value2
100
Value3
1.414
end
Value1
Value1
Value1
Value1
Value1
Value1
Value1
.
.
.
.
.
I want this:
Value1
1000
Value2
100
Value3
1.414
end
Value1
1000
Value2
100
Value3
1.414
end
Value1
1000
Value2
100
Value3
1.414
end
.
.
.