I have been working on this for a long time with no success,
so yea what am I doing wrong here.
I'm trying analyze every word of a string, that means vowels, numbers, signs, and constants.
Code:
#include <stdio.h>
#include <string.h>
int main ()
{
int i, length=0, count=0,vowel=0,constan=0,num=0,sign=0,h=0;
char hi[800];
char hey[800];
fgets (hi,800,stdin);
printf("%s", hi);
length= strlen(hi);
printf("\nlength = %d\n",length);
int j = 0;
for (i = 0; i <= length; i++)
{
if (hi[i] == ' ')
{
count++;
for (h = 0; hey[h] == '\0'; ++h)
{
if (hey[h] == 'a' || hey[h] == 'e'||hey[h] == 'i'||hey[h] == 'o'||hey[h] == 'u')
{++vowel;}
if(hey[h]>'0'&&hey[h]<'9')
{++num;}
if(hey[h] == '.' || hey[h] == '!' || hey[h] == ','||hey[h] == '?'||hey[h] == '('||hey[h] == ')'||hey[h] == '‘'||hey[h] == '“')
{++sign;}
else
{++constan;}
}
hey[j] = '\0';
printf("\n%s\n", hey);
printf("\nVowels: %d",vowel);
printf("\nConsonants: %d",constan);
printf("\nNumbers .-.:%d",num);
printf("\nSigns: %d",sign);
printf("\n");
j = 0;
vowel=0;
constan=0;
num=0;
sign=0;
}
else
{
hey[j++] = hi[i];
}
}
++count;
printf("\nNumber of words :%d",count);
}