Created
June 30, 2020 08:24
-
-
Save Ztuu/dcdd42934719a549e63a79afd41dcaa1 to your computer and use it in GitHub Desktop.
Remove vowels from a 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
#include <stdio.h> | |
#include <string.h> | |
char *disemvowel(const char *str) | |
{ | |
char* result = malloc(strlen(str) + 1); | |
char vowels[] = {'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'}; | |
int counter = 0; | |
while(*(str) != '\0'){ | |
int allowed = 1; | |
for(int i=0; i<10; i++){ | |
if(vowels[i] == *str){ | |
allowed = 0; | |
} | |
} | |
if(allowed){ | |
result[counter++] = *str; | |
} | |
str++; | |
} | |
result[counter] = '\0'; | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment