void RemoveVowels(char *str)
 { 
     
     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]=' ';
                
 
}

     }  

     }

Hey guys having trouble trying to remove the vowels here, i cant figure out were I'm going wrong. thanks in advance.

Are you trying to just turn the vowels into spaces? If so, your code works perfectly on my end.

#include <iostream>          
#include <string.h>          
#include <ctype.h>
using namespace std;

void RemoveSpaces(char *str);
void RemoveVowels(char *str);




int main()
{
    
    
  
char clear[256];
char cipher[256];
int x,i;
int opt;





  

cout<<"Encryption (1) 0r Decryption (2):"<<endl;
cin>>opt;
cin.ignore();

if(opt==1)
{
    
cout<<" Enter a string(sentence):";
 cin.getline(clear,sizeof(clear)); 
  
RemoveSpaces(clear);
RemoveVowels(clear);

x = strlen(clear);

for(i=0;i<=x-1;i++)            
{
cipher[i] = clear[i]+3;
}
cipher[x] = '\0';

cout<<" Encrypted:"<< cipher << endl;
	

}
for(i=0; i<=x-1; i++)
{                                 
    if (isspace(clear[i]))
    {
        cipher[i] = clear[i];
    }
    else
    {
       cipher[i] = clear[i]+3;
    }
  
cout<<cipher[i]<<endl;

 

}
 cin.get();

return 0;

}



void RemoveSpaces(char *str)
{
   int i = 0;
   int lenght = strlen(str);
   while(i < lenght)
   {
      if( isspace(str[i] ))
      {
         memmove(&str[i], &str[i+1], lenght-1);
         --lenght;
      }
      else
          ++i;
          
   
           
   }

 
}  

void RemoveVowels(char *str)
 { 
     
     int i = 0;
     int  lenght = strlen(str);
 
      for(i=0;i < lenght;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]=' ';
             
 
}

     }  

     }

here is my full code i must be positioning RemoveVowels(clear)in the wrong place.

You are calling RemoveSpaces() before you call RemoveVowels() . Did you mean to put this the other way around?

How did you remove spaces? Removing vowels is the same thing, except that you find a vowel instead of a space before you remove it.

Cheers for the input, im new to programming not sure which position they go in. i have the program working now. but i cant get the removal of the vowels from a encrypted string, would this have something to do with the position of removeSpace() or removeVowel(). it will remove vowels from the string without encryption.

Cheers for the tip Lerner got it sorted.

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.