Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Your task is to write a function that takes a string and return a new string with all vowels removed.
- // For example, the string "This website is for losers LOL!" would become "Ths wbst s fr lsrs LL!".
- // Note: for this kata y isn't considered a vowel.
- //solution must allocate all required memory
- //and return a free-able buffer to the caller.
- char *disemvowel(const char *str)
- {
- char *out;
- out = strdup(str);
- for(char *p = out; *p; ++p)
- while(!((*p-'a')*(*p-'e')*(*p-'i')*(*p-'o')*(*p-'u')*(*p-'A')*(*p-'E')*(*p-'I')*(*p-'O')*(*p-'U')))
- memmove(p, p+1, strlen(p));
- return out;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement