Thread: Counting vowels in a string - invalid identifier

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Feb 2012
    Posts
    23

    Counting vowels in a string - invalid identifier

    This is just a small fragment of my code so I didn't include all the vowels.

    Code:
        string response;
        int array [5]= {0, 0, 0, 0, 0};
    
    
        cout << "enter a string of text\n" << endl;
        cin >> response;
     
          for(int i=0;i<strlen(response);i++)
        {
        if response == 'A'        //invalid identifier
            array[i]++;
        if response == 'E'     //invalid identifier
            array[i]++;
           }
    I am getting the error that "response" is not a valid identifier? When I'm trying to check the characters in the string for either A or E and increment the count in the appropriate area of the array...
    Last edited by hencherz; 02-24-2012 at 04:53 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 11-08-2011, 01:13 PM
  2. Need help with counting vowels prog
    By truetrini20 in forum C++ Programming
    Replies: 9
    Last Post: 07-12-2010, 07:44 AM
  3. Replies: 6
    Last Post: 08-11-2008, 12:50 AM
  4. Counting Vowels within a string.
    By patso in forum C Programming
    Replies: 12
    Last Post: 04-09-2008, 04:21 PM
  5. counting vowels
    By trippedwire in forum C++ Programming
    Replies: 10
    Last Post: 10-01-2004, 11:58 PM