remove vowels from user input string

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vinoth66
    New Member
    • Aug 2013
    • 10

    #1

    remove vowels from user input string

    how to remove the vowels from the user input.?
  • vinoth66
    New Member
    • Aug 2013
    • 10

    #2
    Code:
    #include<iostream>
    #include<string>
    #include<sstream>
    using namespace std;
    int main()
    {
    
        char word[1000];
        char b[6]={'a','e','i','o','u'};
        cout<<"enter the word:\t";
        cin>>word;
        for(int i=0;i<=1000;i++)
        {
            char d=word[i];
            if(d==b[0])
            {
    
            }
            else if(d==b[1])
            {
    
            }
            else if(d==b[2])
            {
    
            }
            else if(d==b[3])
            {
    
            }
            else if(d==b[4])
            {
    
            }
            else
                cout<<"\r \n"<<d;
        }
    
    
    }
    Last edited by weaknessforcats; Aug 13 '13, 02:34 PM. Reason: added code tags

    Comment

    • vinoth66
      New Member
      • Aug 2013
      • 10

      #3
      try this and suggest ideas

      Code:
      #include<iostream>
      #include<string>
      #include<sstream>
      using namespace std;
      int main()
      {
      
          char word[1000];
          char b[6]={'a','e','i','o','u'};
          cout<<"enter the word:\t";
          cin>>word;
          for(int i=0;i<=1000;i++)
          {
              char d=word[i];
              if(d==b[0])
              {
      
              }
              else if(d==b[1])
              {
      
              }
              else if(d==b[2])
              {
      
              }
              else if(d==b[3])
              {
      
              }
              else if(d==b[4])
              {
      
              }
              else
                  cout<<"\r \n"<<d;
          }
      
      
      }
      Last edited by weaknessforcats; Aug 13 '13, 02:35 PM. Reason: added code tags

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        The easiest thing to do is to make a copy of your input string. You would write a loop copy from your input a character at a time. Test each character to be a vowel and if it is don't copy it.

        Your copy will have no vowels.

        Finally, copy back to the original input.

        Comment

        • vinoth66
          New Member
          • Aug 2013
          • 10

          #5
          thanks for your help

          Comment

          Working...