Skip to content

Instantly share code, notes, and snippets.

@Ztuu
Created June 30, 2020 08:24
Show Gist options
  • Save Ztuu/dcdd42934719a549e63a79afd41dcaa1 to your computer and use it in GitHub Desktop.
Save Ztuu/dcdd42934719a549e63a79afd41dcaa1 to your computer and use it in GitHub Desktop.
Remove vowels from a string
#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