Question 1
Code:
#include <stdio.h>
#include <string.h>
int main(void)
{
char *lines[] = {"I have a fast car", "Its a Ferrari"};
char LookFor = 'a';
char *ptr;
int count, i;
for (i = 0; i < 2; i++)
{
count = 0;
ptr = lines[i];
while ((ptr = strchr(ptr, LookFor)) != NULL)
{
count++; ptr++;
}
printf("letter %c found %d times in line %d\n", LookFor, count, i+1);
}
return (0);
}
Question 2
Look through each string, counting the number of characters that are deemed to split words. This is not always just the spaces, it could be commas, full stops, exclamation marks etc etc. The choice is yours!
Question 3
Use the function strstr(); Look that one up in the book, it's easy to use.
Question 4
Read this faq page