Remove Signs & Whitespace (w/pointer)
Hey!
Could you by any chance give me some hints why the following function does not work the way it should?
Code:
void removeSign(char *str)
{
char *ptr = str;
while (*ptr != '\0') {
while(!(*ptr > 64 && *ptr < 91) && !(*ptr > 96 && *ptr < 123))
{
ptr++;
}
*str = *ptr;
str++;
ptr++;
}
}
all it should do is remove every sign which isn't a character (a-z, A-Z).
Edit: it only works on some inputs...
I'm especially confused because my similar "remove all whitespace" function seems to work just fine:
Code:
void removeWhitespace(char *str)
{
char *ptr = str;
while (*ptr != '\0')
{
while (isspace(*ptr))
{
ptr++;
}
*str = *ptr;
str++;
ptr++;
}
}