Skip to content

Instantly share code, notes, and snippets.

@denisdemaisbr
Created December 12, 2023 00:25
Show Gist options
  • Save denisdemaisbr/0b25adf7dffb99de3acb833db35cbf4f to your computer and use it in GitHub Desktop.
Save denisdemaisbr/0b25adf7dffb99de3acb833db35cbf4f to your computer and use it in GitHub Desktop.
c function to remove character in string
static void str_remove(void *s, unsigned char target) {
unsigned char* str = (unsigned char*) s;
int len = strlen(str);
int i, j = 0;
for (i = 0; i < len; i++) {
if (str[i] != target) {
str[j++] = str[i];
}
}
str[j] = 0x0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment