Counting Vowels/Consonants using Pointers, Strings and Dynamic Storage

This is a discussion on Counting Vowels/Consonants using Pointers, Strings and Dynamic Storage within the C Programming forums, part of the General Programming Boards category; Hi. So, I am trying to figure out how to read a list of names from the keyboard and count ...

  1. #1
    Registered User
    Join Date
    Nov 2011
    Location
    California!
    Posts
    1

    Counting Vowels/Consonants using Pointers, Strings and Dynamic Storage

    Hi. So, I am trying to figure out how to read a list of names from the keyboard and count the number of vowels and consonants in the list.. I must use dynamic storage, an array of strings, and multiple functions.
    I am really new to this dynamic storage and strings, so my code may be really confusing... I tried, could someone help me? And if you could explain?? thank youu
    PS. I know I haven't used functions but I am trying to get the gist of the dynamic storage stuff and string before I write functions

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <ctype.h>
    #include <string.h>
    
    #define SIZE 10
    
    int main (void)
    {
        char cartoon[101];
        char** pNames;
    
        int nameIndex;
        int vowelCount=0;
        int constCount=0; 
        
    pNames = calloc (size +1, sizeof (char*));
    printf("Please enter cartoon character names\n");
    
    nameIndex = 0;
    while (nameIndex <size && fgets (input, sizeof(input), stdin))
        {
        *(pNames +nameIndex) = (char*)
            calloc (strlen (input) +1, sizeof (char*));
        strcopy (*(pCartoon +nameIndex), cartoon);
    
        if (isalpha(char*))
            {
            toupper(*char)
            if ( *char = 'A' || *char = 'E' || *char = 'I' || *char = 'O' || *char = 'U' || *char = 'Y')
                vowelCount++;
            else
            constCount++;
        nameIndex++;
        }
    
    *(pNames +nameIndex) = NULL;
    printf("\n Cartoon characters are: \n");
    nameIndex = 0;
    while (*(pNames +nameIndex))
        {
        printf(" %3d: %s", nameIndex, *(pNames+nameIndex));
        nameIndex++;
        }
    printf(" There are %d vowels in this list \n\n", vowelCount);
    printf(" There are %d consonants in this list \n\n", constCount);
    return 0;
    }

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    ok... so what's it not doing? What's it doing wrong? What did you expect to happen? what errors is the compiler giving you?

    A real question would be a big help here...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with counting vowels prog
    By truetrini20 in forum C++ Programming
    Replies: 9
    Last Post: 07-12-2010, 08:44 AM
  2. Replies: 47
    Last Post: 11-16-2009, 10:18 PM
  3. Counting Vowels within a string.
    By patso in forum C Programming
    Replies: 12
    Last Post: 04-09-2008, 05:21 PM
  4. Count the number of vowels, consonants, digits etc.
    By kumar14878 in forum C Programming
    Replies: 3
    Last Post: 05-09-2005, 01:34 AM
  5. counting vowels
    By trippedwire in forum C++ Programming
    Replies: 10
    Last Post: 10-02-2004, 12:58 AM

Tags for this Thread


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