- 17.7k
- 1
- 28
- 32
Splice Slice string at ":"
I need to spliceslice a string (eg- 4:288:18464:288:4) at ":" into an array({4, 288, 18464, 288, 4}) I used the following code, but its giving only '4' in the serial monitor when "4:288:18464:288:4," is given to arduino.
void displayString(char* s)
{
char* text = strtok(s,":");
while(text != NULL){
text = strtok(NULL,":");}
}
void loop()
{
if(Serial.available() > 0)
{
str = Serial.readStringUntil(',');
str.toCharArray(text,99);
}
displayString(text);
Serial.println(text);
}
Splice string at ":"
I need to splice a string (eg- 4:288:18464:288:4) at ":" into an array({4, 288, 18464, 288, 4}) I used the following code, but its giving only '4' in the serial monitor when "4:288:18464:288:4," is given to arduino.
void displayString(char* s)
{
char* text = strtok(s,":");
while(text != NULL){
text = strtok(NULL,":");}
}
void loop()
{
if(Serial.available() > 0)
{
str = Serial.readStringUntil(',');
str.toCharArray(text,99);
}
displayString(text);
Serial.println(text);
}
Slice string at ":"
I need to slice a string (eg- 4:288:18464:288:4) at ":" into an array({4, 288, 18464, 288, 4}) I used the following code, but its giving only '4' in the serial monitor when "4:288:18464:288:4," is given to arduino.
void displayString(char* s)
{
char* text = strtok(s,":");
while(text != NULL){
text = strtok(NULL,":");}
}
void loop()
{
if(Serial.available() > 0)
{
str = Serial.readStringUntil(',');
str.toCharArray(text,99);
}
displayString(text);
Serial.println(text);
}
Splice string at ":"
I need to splice a string (eg- 4:288:18464:288:4) at ":" into an array({4, 288, 18464, 288, 4}) I used the following code, but its giving only '4' in the serial monitor when "4:288:18464:288:4," is given to arduino.
void displayString(char* s)
{
char* text = strtok(s,":");
while(text != NULL){
text = strtok(NULL,":");}
}
void loop()
{
if(Serial.available() > 0)
{
str = Serial.readStringUntil(',');
str.toCharArray(text,99);
}
displayString(text);
Serial.println(text);
}