Skip to content

Instantly share code, notes, and snippets.

@namila007
Created April 19, 2017 11:46
Show Gist options
  • Save namila007/eae1287a3e40046073d5914af2002f90 to your computer and use it in GitHub Desktop.
Save namila007/eae1287a3e40046073d5914af2002f90 to your computer and use it in GitHub Desktop.
Removing Non alpha numeric characters (C programming)
char* stringRemoveNonAlphaNum(char *str)
{
int i = 0, j = 0;
int arraysize=strlen(str)+1;
char c;
char *temp=malloc(arraysize* sizeof(char)); //allocatin memory for new string
for(i=0;i<arraysize;i++){
c=str[i];
if(isalnum(c)!= 0){ //if it is not a alpha num put in a new string temp
temp[j++]=c;
}
}
temp[j]='\0'; //make last char null
// return string;
return temp;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment