其他分享
首页 > 其他分享> > c语言 13-9

c语言 13-9

作者:互联网

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(toupper(ch));
                fputc(toupper(ch), dfp);    
            }
            fclose(dfp);
        }
        fclose(sfp);
    } 
    return 0;
}

 

标签:13,ch,语言,dfp,sfp,sfile,printf,dfile
来源: https://www.cnblogs.com/liujiaxin2018/p/14865553.html