Thanks grumpy and your absolutely right. I have been working on this since I've posted my last post and have gotten much further. Now I actually have some specific questions lol. I'm having a bit of trouble figuring out a way to count words. I'm not looking for the straight answer, just hints so I can figure it out my self . Here is what I have:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char string [100];
int slength;
int search (char x);
int main()
{
int finda;
int finde;
int findi;
int findo;
int findu;
int findspace;
printf("Enter a phrase.\n");
fgets(string, 100, stdin);
printf("You entered %s\n",string);
slength = strlen(string)-1;
finda = search ('a') + search ('A');
finde = search ('e') + search ('E');
findi = search ('i') + search ('I');
findo = search ('o') + search ('O');
findu = search ('u') + search ('U');
findspace = search (' ');
printf("There were %d letter a's in your phrase\n", finda);
printf("There were %d letter e's in your phrase\n", finde);
printf("There were %d letter i's in your phrase\n", findi);
printf("There were %d letter o's in your phrase\n", findo);
printf("There were %d letter u's in your phrase\n", findu);
printf("There were %d spaces in your phrase\n", findspace);
return 0;
}
int search (char x)
{
int counter = 0;
int stringpos;
for(stringpos=0; stringpos<=slength; stringpos++)
if(string[stringpos] == x)
counter++;
return counter;
}