Test is an array of char, not a class with member functions, therefor the replace() is not existant => compiler error
From the code I see you want to remove the spaces, you can use an inplace remove like below
#include <string.h>
void setup()
{
Serial.begin(19200);
}
void loop()
{
char test[] = "s1: 22, s2: 43, s3: 12, s4: 56";
// test = test.replace(' ', '');
Serial.println(test);
remove(test, ' ');
Serial.println(test);
char *token = strtok(test, ",");
int i = 1;
while(token)
{ // Do something with this word
Serial.print(token);
Serial.println();
token = strtok(NULL, ",");
i +=1;
}
Serial.println();
delay(1000);
}
void remove(char *str, char r)
{
char *p, *q;
p = q = str;
while (*p != '\0')
{
while (*p == r) p++;
*q++ = *p++;
}
*q = '\0';
}