Hey Guys im looking to remove vowels, im having trouble trying to remove them, any tip or help i would appreciate it thanks.

void RemoveVowels(char *str)
 { 
     int x =0;
     int i = 0;
     int  lenght = strlen(str);
      
      
     for(i=0;i=lenght-1;i++)
     
{

 
             
        
              if (str[i]=='a' || str[i]=='e' || str[i]=='i' || str[i]=='o' || str[i]=='u' || str[i]=='A' || str[i]=='E' || str[i]=='I' || str[i]=='O' || str[i]=='U') {
str[i]=' '; 
      
      
        
}
}
}

I'd suggest you move to C++ containers ( std::string, std::remove_copy_if ) to make your life easier but that is another issue.

The easiest way to remove elements from an array is to create a new array of exactly the same size as the original. Loop over each value in the original array copying the items you want to the new array in order while ignoring the values you do not want. This requires two counters but makes the semantics of the copy much easier.
Since your function is void you will want to copy the new array (after looping) to the original array before returning from the call.

The solution is identical to the RemoveSpaces() program I showed you in the other thread except check for vowels instead of saces.

thanks but not to sure how to check for vowels here is what i did.

void RemoveVowels(char *str)
 { 
     int x =0;
     int i = 0;
    //int  lenght = strlen(str);
    int vowel = strlen(str);
       while(i < vowel)
       {
        
 if (str[i]=='a' || str[i]=='e' || str[i]=='i' || str[i]=='o' || str[i]=='u' || str[i]=='A' || str[i]=='E' || str[i]=='I' || str[i]=='O' || str[i]=='U') {
str[i]=' '; 

  memmove(&str[i], &str[i+1], vowel-1);
         --vowel;
      
} 
else
++i;    
        

}
}

Did you test your function? Looks ok to me, except you can delete line 11 where it sets the character to a space.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.