not sure how to pull vowels out of strings?

This is a discussion on not sure how to pull vowels out of strings? within the C++ Programming forums, part of the General Programming Boards category; i'm having trouble in pulling out just the vowels from a string. not sure if i should use a for ...

  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    1

    Question not sure how to pull vowels out of strings?

    i'm having trouble in pulling out just the vowels from a string. not sure if i should use a for loop and just compare each letter or is there a better way?
    Thanks in advance.

  2. #2
    Registered User
    Join Date
    Aug 2002
    Posts
    87
    I believe that using a for loop would be the most efficient way of doing it, there might be some functions that will halp you do it but these usually have extra code that only take up extra CPU time...

  3. #3
    Registered User
    Join Date
    Nov 2002
    Posts
    1,109
    just compare the elements to the vowels, and do this in a for loop.

  4. #4
    Registered User
    Join Date
    Feb 2003
    Posts
    162
    Code:
    for (int i = 0; i < strlength; i++)
    {
          if (isalpha(ch))
          {
                if (ch == 'A' || ch == 'a' || ch == 'E' etc........)
                      //do whatever joo want
          }
    }

  5. #5
    Registered User axon's Avatar
    Join Date
    Feb 2003
    Posts
    2,572
    instead of
    Code:
    if (ch == 'A' || ch == 'a' || ch == 'E' etc........)
    I would definately write a function called isvowel(), the code be much neater that way

    axon

    some entropy with that sink? entropysink.com

    there are two cardinal sins from which all others spring: Impatience and Laziness. - franz kafka

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Strings Program
    By limergal in forum C++ Programming
    Replies: 4
    Last Post: 12-02-2006, 03:24 PM
  2. Programming using strings
    By jlu0418 in forum C++ Programming
    Replies: 5
    Last Post: 11-26-2006, 08:07 PM
  3. Reading strings input by the user...
    By Cmuppet in forum C Programming
    Replies: 13
    Last Post: 07-21-2004, 07:37 AM
  4. damn strings
    By jmzl666 in forum C Programming
    Replies: 10
    Last Post: 06-24-2002, 03:09 AM
  5. menus and strings
    By garycastillo in forum C Programming
    Replies: 3
    Last Post: 04-29-2002, 12:23 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21