C语言读取文件将大写字母转化为小写字母

#include 
#include 
#include 

int main ()
{
    FILE *fp;
    char Filename[50], ch;
    int a = 0;
    printf("Enter PathName:");
    scanf("%s", Filename);
    if((fp = fopen(Filename, "r")) == NULL)
    {
        printf("File open failed!\n");
        exit(0);
    }
    while(!feof(fp))
    {
        ch = fgetc(fp);
        if(ch != EOF)
        {
            if(ch >= 'A' && ch <= 'Z')
            {
                ch += 32;
            }
            if(ch == '\n')
            {
                a++;
            }
            printf("%c", ch);
        }
    }
    printf("%d\n", a);
    return 0;
}

你可能感兴趣的:(C++)