This is probably the most efficient.
char data[] = "8 0495: <0x221> [7] 02 20 4e 65 04 a5 a5";
static void replace(char *data)
{
const char *cursor = data;
while (*cursor)
{
if ( memcmp(cursor, ": <", 3) == 0)
{
cursor += 3;
*data++ = ',';
}
else if ( memcmp(cursor, "> [", 3) == 0)
{
cursor += 3;
*data++ = ',';
}
else if ( memcmp(cursor, "] ", 2) == 0)
{
cursor += 2;
*data++ = ',';
}
else
{
cursor++;
data++;
}
}
*data++ = 0;
}
If you prefer to work with STL strings, try this:
string::replace - C++ Reference[
^]