smash.txt
snippets · 480 B · 2010-03-30
Smash: strips all color codes from a string.
Download « Back to the snippets list
// Smash all the colour codes.
// This smashes from the seed and will return a
// pointer to the seed. Do not use this if you
// don't want to change the original string.
// This also will no totally remove {, it adds in
// another one so it goes unnoticed.
char * smash_colour(char *buf) {
char *ptr;
for (ptr = buf; *ptr; ++ptr)
if (*ptr == '{') {
++ptr;
memmove(ptr, ptr-1, strlen(ptr-1));
}
return buf;
}