Skip to content

Instantly share code, notes, and snippets.

@Morse-Code
Created April 4, 2013 12:41
Show Gist options
  • Save Morse-Code/5310046 to your computer and use it in GitHub Desktop.
Save Morse-Code/5310046 to your computer and use it in GitHub Desktop.
Remove non-alphanumeric characters from a C string.
void stringRemoveNonAlphaNum(char *str)
{
unsigned long i = 0;
unsigned long j = 0;
char c;
while ((c = str[i++]) != '\0')
{
if (isalnum(c))
{
str[j++] = c;
}
}
str[j] = '\0';
// return str;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment