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;
}