Advertisement
Guest User

Untitled

a guest
Aug 18th, 2021
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.63 KB | None | 0 0
  1. // Your task is to write a function that takes a string and return a new string with all vowels removed.
  2.  
  3. // For example, the string "This website is for losers LOL!" would become "Ths wbst s fr lsrs LL!".
  4.  
  5. // Note: for this kata y isn't considered a vowel.
  6.  
  7. //solution must allocate all required memory
  8. //and return a free-able buffer to the caller.
  9.  
  10. char *disemvowel(const char *str)
  11. {
  12.     char *out;
  13.  
  14.     out = strdup(str);
  15.  
  16.     for(char *p = out; *p; ++p)
  17.         while(!((*p-'a')*(*p-'e')*(*p-'i')*(*p-'o')*(*p-'u')*(*p-'A')*(*p-'E')*(*p-'I')*(*p-'O')*(*p-'U')))
  18.             memmove(p, p+1, strlen(p));
  19.  
  20.     return out;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement