Q:

Search how many characters are in a C string

My task is to count how many characters are in a C string. The input is provided by a test driver that I don't have access to but my function is supposed to access the data and determine how many characters range from a-z and A-Z but my program keeps failing and I'm not sure what I'm doing wrong.
int countLetters(char * const line)
{
    char index = *line;
    int count;

   while(!index)
    {
        if (index >= 'a' && index <= 'z')
            count++;

        if (index >= 'A' && index <= 'Z')
            count++;
    }
    return count;

}

A:

Try this  
int countLetters(char * const line)
{
    int index = 0;
    int count = 0;

    while(line[index])
    {
        if (line[index] >= 'a' && line[index] <= 'z')
            count++;

        if (line[index] >= 'A' && line[index] <= 'Z')
            count++;

        index++;
    }
    return count;
}

Here's what you did wrong
First: You assign your char index = *line;
making your index the first character in the string, which is wrong, because index suppose to represent position, not a character
Second: You didnt provide any mechanism to increase the index in other to loop the string
Third: You didnt initialize your count variable

Note: line[index] is the same as *(line + index)
  Your line is a pointer which point to the first character in the string
  So line + index is a pointer that point to the index-nth character in the string
  By prefix a pointer with a * you're saying that i want to know the content that this pointer point to

