木叶乌鸦 发表于 2006-6-28 14:48

教我用下磁盘间既文件复制吖~

void copyrecord(void)
{FILE*in,*out;
char ch,infile,outfile;
printf("Enter the infile name:\n");
scanf("%s",infile);
printf("Enter the outfile name:\n");
scanf("%s",outfile);
if((in=fopen(infile,"r"))==NULL)
    {printf("cannot open infile\n");
   exit(0);
    }
if((out=fopen(outfile,"w"))==NULL)
    {printf("cannot open outfile\n");
   exit(0);
    }
while(!feof(in))fputc(fgetc(in),out);
fclose(in);
fclose(out);}


吾识用衣个程序
成日话我打吾开个infilm
高手讲解下啦~

powerwind 发表于 2006-6-28 16:01

第一步,在D盘建个文件夹叫“Test”,则路径为:“D:\Test”,然后在Test文件夹下面那个Test.c的文件,把上面的代码Copy进去,记得要在前面加上#include<stdio.h>,然后在后面加上

//这里是你上面的程序
int main()
{
   copyrecord();
   return 0;
}

然后编译链接,在Test文件夹下生成Test.exe的可执行文件。

第二步,在Test文件下新建文件,名叫“test.txt”,用记事本打开,有意无意地写些字,保存。

第三步,在开始->所有程序->附件,打开命令提示符,然后输入:
1,"d:",回车
2,“cd test”,回车
3,“test.exe”,回车
4,程序输出“Enter the infile name:”,你就输入“test.txt”,回车。
5,程序输出“Enter the outfile name:”,你就输入“t.txt”,回车。
Done

天命 发表于 2006-6-28 22:04

文件名要带路径吧

powerwind 发表于 2006-6-28 22:06

当前目录下的可以不用

木叶乌鸦 发表于 2006-6-28 22:51

做吾出啊~~~~~

hjack 发表于 2006-6-28 22:54

我记得powerwind有张贴写的是 copy的.

hjack 发表于 2006-6-28 22:55

https://www.gdutbbs.com/viewthread.php?tid=58079&highlight=copy

powerwind 发表于 2006-6-28 22:57

楼主那个程序是正确的。LZ是不会运行。我已经一步步写出来了。
谁叫现在是windows时代,DOS命令过时呢?

hjack 发表于 2006-6-28 22:58

上面的是用C++的.

这个是用C的.https://www.gdutbbs.com/viewthread.php?tid=60335

木叶乌鸦 发表于 2006-6-28 23:10

但系衣个系整个程序既一部分
系米要成个编译连接架?

hjack 发表于 2006-6-28 23:13

沙发的已说得好清楚了啊..

???

powerwind 发表于 2006-6-28 23:16


#include<stdio.h>
void copyrecord(void)
{
        FILE*in,*out;
        char ch,infile,outfile;

        printf("Enter the infile name:\n");
        scanf("%s",infile);
        printf("Enter the outfile name:\n");
        scanf("%s",outfile);
        if((in=fopen(infile,"r"))==NULL)
        {
                printf("cannot open infile\n");
                exit(0);
        }
        if((out=fopen(outfile,"w"))==NULL)
        {
                printf("cannot open outfile\n");
                exit(0);
        }
        while(!feof(in))fputc(fgetc(in),out);
        fclose(in);
        fclose(out);
}


int main()
{
        copyrecord();
        return 0;
}



如果还是不行,哎!~~???????
页: [1]
查看完整版本: 教我用下磁盘间既文件复制吖~