I am currently trying to write a program that:
Write a program to count and print out the number of copies of the letter 'e' that are found in a pre-specified string. (By "pre-specified", I mean you should declare and initialize the string right in your program, rather than reading it in from the command-line.) The count should be accurate regardless of what the string is defined to be. Add a brief comment at the beginning of the file describing what the program does.
The program output should look like:In the following string:
"You may put any string you choose here"
The letter 'e' appears 3 times
I am having lots of trouble with this as I don't even know where to begin. This is what I have so far:
int main ( )
{
char sentence [] = "This is my sentence for the nume.c part of the lab";
int ecount = e;
printf ("In the following string:\n");
printf (" %s\n", sentence);
return(0);
}
I just don't know where to go from there. I was told that it would be a good idea to make the letter you are searching for be #defined as a constant.
I am a beginner in C and I am just learning, so please try to explain it in a way I will understand.