sunnyrubik 发表于 2018-12-9 17:44:31

C语言中文件处理的问题

在56课中,我跟着小甲鱼老师做,可是出来的却是文件打开时失败
我在文件夹里面也放了hello.txt啊。希望大家能帮忙看看,谢谢

#include<stdio.h>
#include<stdlib.h>

int main(void)
{
        FILE *fp1;
        FILE *fp2;
        int ch;
       
        if((fp1 = fopen("hello.txt","r")) == NULL);
        {
                printf("文件打开失败!");
                exit(EXIT_FAILURE);
        }
       
        if((fp2 = fopen("fishc.txt","w")) == NULL);
        {
                printf("文件打开失败!");
                exit(EXIT_FAILURE);
        }
       
        while((ch = fgetc(fp1)) != EOF)
        {
                fputc(ch,fp2);
        }
       
        fclose(fp1);
        fclose(fp2);
       
        system("pause");
        return 0;
}




ba21 发表于 2018-12-9 17:44:32

if((fp1 = fopen("hello.txt","r")) == NULL);
if((fp2 = fopen("fishc.txt","w")) == NULL);

; 号是几个意思?

sunnyrubik 发表于 2018-12-9 19:47:40

ba21 发表于 2018-12-9 17:44
if((fp1 = fopen("hello.txt","r")) == NULL);
if((fp2 = fopen("fishc.txt","w")) == NULL);



{:9_240:}
页: [1]
查看完整版本: C语言中文件处理的问题