// 04222008.cpp, P H Anderson, Apr 22, '08

#include <stdio.h>

#define WAIT()  while(getchar() != 'x')

int main()
{ 
    // open a file and count the number of alphabetical characters
    FILE *fr;
    char ch;
    int count = 0;
    
    fr = fopen("c:\\text.txt", "rt");
    if (fr == NULL)
    {
        printf("Unable to open file.\n");
    }
    else
    {
        while(1)
        {
            ch = fgetc(fr);
            if (ch == EOF)
            {
                printf("The number of alphabetical chars is %d.\n", count);
                break;
            }
            else
            {
                ++count;
            }
        }
    }

    WAIT();
}