I've got an array of char* with serial data that I'm trying to remove ':' from. I have tried to iterate through the char*, find and remove any colons but it just comes out as garbage.
char* espData[15];
// pull data from serial and tokenize with strtok > feed to espData
for(int x = 0; x < index-1; x++){
size_t nullTerm = strlen(espData[x]);
espData[x][nullTerm - 1] = '\0';
char* output
for(size_t i = 0; i < strlen(espData[x]); ++i){
if(espData[x][i] != ':') output += espData[x][i];
}
espData[x] = output;
Serial.println(espData[x]);
}
Moving the null character works fine (I wanted to get rid of the last character in every string). Most of the answers I found for general C++ used std::string which we don't have access to.
char*
does nothing to its contents.tokenize with strtok
suggests your code uses strtok, which would be one (probably bloated) solution - yet your code doesn't use strtok!!?espData[x][nullTerm - 1] = '\0';
is redundant codenullTerm
is0
!