Thread: Need Help Finishing Program to Count Vowels and Consonants Using a Pointer to a C-str

  1. #1
    Registered User
    Join Date
    Nov 2018
    Posts
    3

    Need Help Finishing Program to Count Vowels and Consonants Using a Pointer to a C-str

    I am trying to finish a program to display a menu counting the number of vowels in a string entered, count the numbers of the consonants entered in the string entered, and to count both to count the vowels and consonants in the string. And the program needs to be terminated by entering an 'e' for the choice for the menu.

    I need some help filling in the missing code and piecing the code together.


    Code:
    #include <iostream>
    #include <string>
    
    
    using namespace std;
    
    
    // function prototypes
    countVowels (int);
    countConsanants (int);
    countVowAndCon (int);
    entAntStr (int);
    
    
    int main()
    {
        string countString;
        string anthString;
    
    
        cout << "Please type in a sentence about anything: " << endl;
        cin >> countString;
    
    
        cout << "Please enter another sentence: " << endl;
        cin >> anthString;
    
    
        return 0;
    }
    
    
    // user defined functions
    int countVowels (int countval) {
        index;
    
    
        for (index = 0; index < countString; index++) {
    
    
        }
    }
    
    
    int countConsants (int countval) {
        index;
    
    
        for (index = 0; index < countString; index++) {
    
    
        }
    }
    
    
    int countVowAndCon (int countval) {
        index;
    
    
        for (index = 0; index < countString; index++) {
    
    
        }
    }
    
    // user defined functions
    
    
    int countVowAndCon( char * my_c_string)
    {
         int count = 0;
         for( int i = 0; my_c_string[i] != '\0'; ++i)
         {
            // check if my_c_string[i] is a vowel or a consonant
          }
          return count;
    }

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    27,269
    These are wrong:
    Quote Originally Posted by radskater
    Code:
    // function prototypes
    countVowels (int);
    countConsanants (int);
    countVowAndCon (int);
    entAntStr (int);
    Your function prototypes must include the return type. They should also include the parameter names, although these are optional... and while trying to modify your code to show you what to do, I discovered a negative side-effect of your removal of the parameter names: you got the parameter type wrong for countVowAndCon! If you have kept the paremeter name, you are more likely to have discovered this mistake yourself.

    Quote Originally Posted by radskater
    I need some help filling in the missing code and piecing the code together.
    What have you tried for the "missing code"?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Trying to count vowels... in every word of a string.
    By JohnnyC in forum C Programming
    Replies: 4
    Last Post: 11-06-2018, 08:05 AM
  2. Replies: 1
    Last Post: 11-08-2011, 01:13 PM
  3. cant understand this , count vowels
    By y0us3f in forum C Programming
    Replies: 2
    Last Post: 10-24-2011, 06:56 PM
  4. Replies: 47
    Last Post: 11-16-2009, 10:18 PM
  5. Count the number of vowels, consonants, digits etc.
    By kumar14878 in forum C Programming
    Replies: 3
    Last Post: 05-09-2005, 12:34 AM

Tags for this Thread