c语言 13-10

1、

#include <stdio.h>
#include <ctype.h>

int main(void)
{
    int ch;
    FILE *sfp;
    FILE *dfp;
    char sfile[FILENAME_MAX];
    char dfile[FILENAME_MAX];
    
    printf("sfile name: "); scanf("%s", sfile);
    printf("dfile name: "); scanf("%s", dfile);
    
    if((sfp = fopen(sfile, "r")) == NULL)
        printf("\aSfile open failed.\n");
    else
    {
        if((dfp = fopen(dfile, "w")) == NULL)
            printf("\aDfile open failed.\n");
        else
        {
            while((ch = fgetc(sfp)) != EOF)
            {
                putchar(tolower(ch));
                fputc(tolower(ch), dfp);
            }
            fclose(dfp);
        }
        fclose(sfp);
    }
    return 0;
}

 

posted @ 2021-06-09 09:39  小鲨鱼2018  阅读(45)  评论(0编辑  收藏  举报