工大后院

 找回密码
 加入后院

扫一扫,访问微社区

QQ登录

只需一步,快速开始

搜索
查看: 1842|回复: 11

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

[复制链接]
发表于 2006-6-28 14:48 | 显示全部楼层 |阅读模式
void copyrecord(void)
{FILE*in,*out;
char ch,infile[10],outfile[10];
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
高手讲解下啦~
发表于 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 | 显示全部楼层
文件名要带路径吧
回复

使用道具 举报

发表于 2006-6-28 22:06 | 显示全部楼层
当前目录下的可以不用
回复

使用道具 举报

 楼主| 发表于 2006-6-28 22:51 | 显示全部楼层
做吾出啊~~~~~
回复

使用道具 举报

发表于 2006-6-28 22:54 | 显示全部楼层
我记得powerwind有张贴写的是 copy的.
回复

使用道具 举报

发表于 2006-6-28 22:55 | 显示全部楼层
回复

使用道具 举报

发表于 2006-6-28 22:57 | 显示全部楼层
楼主那个程序是正确的。LZ是不会运行。我已经一步步写出来了。
谁叫现在是windows时代,DOS命令过时呢?
回复

使用道具 举报

发表于 2006-6-28 22:58 | 显示全部楼层
上面的是用C++的.

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

使用道具 举报

 楼主| 发表于 2006-6-28 23:10 | 显示全部楼层
但系衣个系整个程序既一部分
系米要成个编译连接架?
回复

使用道具 举报

发表于 2006-6-28 23:13 | 显示全部楼层
沙发的已说得好清楚了啊..

???
回复

使用道具 举报

发表于 2006-6-28 23:16 | 显示全部楼层

  1. #include<stdio.h>
  2. void copyrecord(void)
  3. {
  4.         FILE*in,*out;
  5.         char ch,infile[10],outfile[10];

  6.         printf("Enter the infile name:\n");
  7.         scanf("%s",infile);
  8.         printf("Enter the outfile name:\n");
  9.         scanf("%s",outfile);
  10.         if((in=fopen(infile,"r"))==NULL)
  11.         {
  12.                 printf("cannot open infile\n");
  13.                 exit(0);
  14.         }
  15.         if((out=fopen(outfile,"w"))==NULL)
  16.         {
  17.                 printf("cannot open outfile\n");
  18.                 exit(0);
  19.         }
  20.         while(!feof(in))fputc(fgetc(in),out);
  21.         fclose(in);
  22.         fclose(out);
  23. }


  24. int main()
  25. {
  26.         copyrecord();
  27.         return 0;
  28. }

复制代码


如果还是不行,哎!~~???????
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 加入后院

本版积分规则

QQ|Archiver|手机版|小黑屋|广告业务Q|工大后院 ( 粤ICP备10013660号 )

GMT+8, 2024-5-29 13:55

Powered by Discuz! X3.5

Copyright © 2001-2024 Tencent Cloud.

快速回复 返回顶部 返回列表