Created
April 19, 2017 11:46
-
-
Save namila007/eae1287a3e40046073d5914af2002f90 to your computer and use it in GitHub Desktop.
Removing Non alpha numeric characters (C programming)
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
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