Creating a removeVowel function for Loops...

This is a discussion on Creating a removeVowel function for Loops... within the C++ Programming forums, part of the General Programming Boards category; Hi, Here is the problem that I was given: Write a program that reads in a collection of strings and ...

  1. #1
    Registered User
    Join Date
    Sep 2007

    Creating a removeVowel function for Loops...


    Here is the problem that I was given:

    Write a program that reads in a collection of strings and displays each string read with the vowels removed. For example, if the data strings are:

    *** (sentinel)

    the output would be:


    Write and call a function removeVowel with prototype

    string removeVowel (string);

    that returns its argument string with the vowels removed.

    So far as I can guess, the program should begin as follows, I'm just hung up on removing the vowels:

    for (cin >> words; words != SENTINEL; cin >> words)
    cout << words << endl;
    Any help is appreciative...

  2. #2
    Registered User
    Join Date
    Oct 2006
    i dont know what the dots are, but the first thing you should always write for a function is the definition/signature/header (you can say 'prototype' here, but it isnt exactly), along with the opening and closing parentheses.
    for example, here is a function that takes in an integer x and returns its square, as an int:
    int sq(int x)
       return x*x;
    also, i would read up about for loops, for example, here:

    as with all functions/algorithms in programming, you should start by thinking about the problem in english, not in programming. if you can do that from the start, i guarantee you will be a better programmer than if you hadnt. the best way to think of it is like writing a recipe. that is, step-by-step exact instructions on how to solve the problem. pretend you have to tell a child how to do this, what would you tell them? that is what you need to tell the computer, because it doesnt know anything.

    now, after you think about the problem, have a look at the c++ String class functions here: a good one to look into might be the erase function.
    erase removes characters from a string
    that seems like what you want to do, right?

    again, hope it helps.

    ps, if your stuck and when you want to post back, please give us some details as to what youve tried and where your stuck, in english or in c++.
    Last edited by nadroj; 10-31-2007 at 08:33 PM.

  3. #3
    dra is offline
    Weak. dra's Avatar
    Join Date
    Apr 2005
    i'm not sure if that for loop is correct, but you can rewrite it as

    while ( cin >> x && x != "SENTINEL" ){/*.....*/)
    also, the standard library provides functions that may be useful for you, such as find

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Troubleshooting Input Function
    By SiliconHobo in forum C Programming
    Replies: 14
  2. C++ compilation issues
    By Rupan in forum C++ Programming
    Replies: 1
    Last Post: 08-22-2005, 05:45 AM
  3. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
  4. Question..
    By pode in forum Windows Programming
    Replies: 12
  5. c++ linking problem for x11
    By kron in forum Linux Programming
    Replies: 1
