#delete vowels in c

19 messages · Page 1 of 1 (latest)

verbal ridgeBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

humble thunder
#

I used this function

char delete_vowels(char *str)
{
  int len = strlen(str);
  for(int i =0 ; i< len ; i++)
  {
    if (str[i]=='a'  str[i]=='i'  str[i]=='u' str[i]=='e' str[i]=='o' str[i]=='A'  str[i]=='I'  str[i]=='U' str[i]=='E'|| str[i]=='O' )
    for (int j = i ; j < len ; j++)
    {
      str[j] = str [ j + 1];
    }
    len--;
  }
  return str ;
}

This is in int main

Char str[100];
Printf(" inpur str : ")
Scanf("%s", str)
printf(" Output : %s ", delete_vowels(str));

winged bone
#
str[i]=='a'  str[i]=='i'  str[i]=='u' str[i]=='e' str[i]=='o' str[i]=='A'  str[i]=='I'  str[i]=='U' str[i]=='E'|| str[i]=='O'
```are there supposed to be `||` inbetween all of these?
#

Also what is not working?

humble thunder
#

Yes

#

I had to write || too

#

But idk why it missing when i send the code in this chat

winged bone
#

I mean there are multiple solutions. Either you write a delete_char(char * str, char to_delete) function and invoke it for all chars you want to delete individually, or if you want to solution better designed for your individual problem then you can just iterate over the string and whenever a char is not a vowel copy it as the next character into a second string

humble thunder
#

What does variables to_delete for?

winged bone
#

Beg your pardon?

humble thunder
#

Char to_delete

winged bone
#

Yes?

humble thunder
#

For?

winged bone
#

What is your question?

humble thunder
#

Maybe save the new string or?

winged bone
#

Please make a whole sentence out of your question, I don't understand what you want

humble thunder
#

Hmmm forget it , now how to iterate over the string?