#include <iostream>
#include <stdio.h>

using namespace std;

void my_copy(const char* src_file, const char* dest_file)
{
  FILE *in_file, *out_file;
  in_file = fopen(src_file, "rb");
  if (in_file == NULL)
  {
    throw 1;
  }

  out_file = fopen(dest_file, "wb");
  if (out_file == NULL)
  {
    throw 2;
  }

  char rec[1024];
  size_t bytes_in, bytes_out;
  while ((bytes_in = fread(rec, 1, 1024, in_file))>0)
  {
    bytes_out = fwrite(rec, 1, bytes_in, out_file);
    if (bytes_in != bytes_out)
    {
      throw 3;
    }
  }
  fflush(out_file);
  fclose(out_file);
  fclose(in_file);

  
}

int main()
{
  try
  {
    my_copy("D:\\File\\1.txt", "D:\\File\\20190608\\1.txt");
  }
  catch (int e)
  {
    switch (e)
    {
    case 1:
      printf("打开源文件出错\n");
      break;
    case 2:
      printf("打开目标文件出错\n");
      break;
    case 3:
      printf("拷贝文件出错\n");
      break;
    default:
      printf("未知错误\n");
      break;
    }
  }

  system("pause");
  return 0;
}

最新文章

  1. 屌丝giser成长记-大学篇
  2. linux下命令运行目录上程序前面要加./
  3. openssl API网络通信
  4. ubuntu13.04云主机部署gitlab6.6
  5. tty &amp; pty &amp; pts
  6. 【ASP.NET基础】简单企业产品展示网站--产品编辑CRUD
  7. mvc路由规则相关
  8. [精校版]The Swift Programming Language
  9. javascript数组总结(0504)
  10. bzoj2705
  11. Teacher YYF - POJ 3746(打表........)
  12. 第一个输出程序 Console.WriteLine
  13. 在调试安卓系统的时候需要这个 ”adb disable-verity“
  14. NTT中可用素数模数原根表
  15. 2883 -- 【TJOI2018】游园会
  16. CSS魔法堂:那个被我们忽略的outline
  17. 大端&amp;小端问题
  18. 17秋 软件工程 团队第五次作业 Alpha Scrum6
  19. Java自定义类加载和ClassPath类加载器
  20. 什么是Platform Services Controller

热门文章

  1. MFC编程——Where is WinMain?
  2. Ubuntu系统---开机总会显示错误报告处理
  3. PHP--极光推送
  4. Maya mel maya档出现未知插件解决方法
  5. BackGroundWorker组件使用、Winform控件的Invoke安全调用
  6. python yaml文件内容的读取
  7. web上传下载文件
  8. 日常note
  9. Python 8--异常
  10. FFmpeg处理音视频流程学习笔记