Created
December 12, 2023 00:25
-
-
Save denisdemaisbr/0b25adf7dffb99de3acb833db35cbf4f to your computer and use it in GitHub Desktop.
c function to remove character in string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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