Write a program to delete all vowels from a sentence. Assume that the sentence is not
more than 80 characters long.
#include <stdio.h>
char* del_vowels(char* s) {
char* vowels = "aeiouyAEIOUY";
int n = 12;
int is_vowel;
int i;
char* p = s;
char* q = p;
while (*p != '\0') {
is_vowel = 0;
for (i=0; i<n; i++) {
if (*p == vowels[i]) {
is_vowel = 1;
break;
}
}
if (!is_vowel) {
*q = *p;
q++;
}
p++;
}
*q = *p;
return s;
}
int main()
{
char buf[80];
printf("Entera a sentence:\n");
gets(buf);
del_vowels(buf);
printf("The sentece withowt vowels is:\n%s\n", buf);
return 0;
}
Comments
Leave a comment