#include<iostream.h>

#include<stdlib.h>

#include<string.h>

#include<fstream.h>

struct staff{

long staNum;

char staName[500];

long phoNum;

long num;

char staAddr[1000];

}staf,staf1;

void main(){

fstream fstr1,fstr2,fstr,fstrt;

char i,fn1[80],fn2[80],fn[80],fnt[80],*p1,*p2,*p,*pt,str[1000];

//staff staf1;

int a,b;

p1=&fn1[0]; p2=&fn2[0]; p=&fn[0]; pt=&fnt[0];

cout<<"Please input the file name of fn1:\n";

//cin>>p1;

//fstr1.open(p1,ios::binary|ios::in|ios::out);     //1

fstr1.open("E:\\新建文件夹\\新建文件夹\\a.bat",ios::binary|ios::in|ios::out);

if(!p1){ cerr<<"Can't open the file fn1.\n"; return; }

fstr1.seekp(0,ios::end);

cout<<"Please input the number i(Y|y).\n";

cin>>i;

while(i=='Y'||i=='y'){

cout<<"Please input the number staf.\n";

cin>>staf.staNum>>staf.staName>>staf.phoNum>>staf.num>>staf.staAddr;

fstr1.write((char *) &staf,sizeof(staf));    //文件名对象.write函数里的buffer类型只能是(char *),不能是其他类型fstr1.write((int *) &a,sizeof(a));

cout<<"Please input the number i.(Y|y)\n";

cin>>i;  }

cout<<"Please input the file name of fn2:\n";

//cin>>p2;

//fstr2.open(p2,ios::binary|ios::in|ios::out);   //2

fstr2.open("E:\\新建文件夹\\新建文件夹\\b.bat",ios::binary|ios::in|ios::out);

if(!p2){ cerr<<"Can't open the file fn2.\n"; return; }

fstr2.seekp(0,ios::end);

cout<<"Please input the number i.(Y|y)\n";

cin>>i;

while(i=='Y'||i=='y'){

cout<<"Please input the number staf1.\n";

cin>>staf1.staNum>>staf1.staName>>staf1.phoNum>>staf1.num>>staf1.staAddr;

fstr2.write((char *) &staf1,sizeof(staf1));

cout<<"Please input the number i(Y|y).\n"; cin>>i;  }

cout<<"Please input the file name of fn.\n";    //3

//cin>>p;

//fstr.open(p,ios::binary|ios::in|ios::out);

fstr.open("E:\\新建文件夹\\新建文件夹\\file.bat",ios::binary|ios::in|ios::out);

if(!p){ cerr<<"Can't open the file of fn.\n"; return; }

fstr1.seekp(0,ios::end);

long pEnd1=fstr1.tellp();

fstr2.seekp(0,ios::end);

long pEnd2=fstr2.tellp();

fstr1.seekp(0,ios::beg);

fstr2.seekp(0,ios::beg);

while(fstr1.tellp()!=pEnd1&&fstr2.tellp()!=pEnd2){

fstr1.read((char *) &staf,sizeof(staf));

fstr2.read((char *) &staf1,sizeof(staf1));

if(staf.staNum>>staf1.staNum) fstr.write((char *) &staf,sizeof(staf));

else fstr.write((char *) &staf1,sizeof(staf1));

//fstr<<staf1.staNum<<ends<<staf1.staName<<ends<<staf1.phoNum<<ends<<staf1.num<<staf1.staAddr;     }

while(fstr1.tellp()!=pEnd1) fstr.write((char *) &staf,sizeof(staf));

while(fstr2.tellp()!=pEnd2) fstr.write((char *) &staf1,sizeof(staf1));

cout<<"Please input the file name of fn4.\n";    //4

//cin>>pt;

//fstrt.open(pt,ios::in|ios::out);

fstrt.open("E:\\新建文件夹\\新建文件夹\\l.txt",ios::in|ios::out);

if(!pt){ cerr<<"Can't open the file of fn.\n"; return; }

fstr.seekg(0,ios::end);

long pEnd3=fstr.tellg();

fstr.seekg(0,ios::beg);

while(fstr.tellg()!=pEnd3){

fstr.read((char *) &staf,sizeof(staf));

fstrt<<staf.staNum<<ends<<staf.staName<<ends<<staf.phoNum<<ends<<staf.num<<staf.staAddr<<endl;

cout<<staf.staNum<<ends<<staf.staName<<ends<<staf.phoNum<<ends<<staf.num<<staf.staAddr<<endl;

} cout<<endl; fstrt.close();

cout<<"Please input the file name of fn4.\n";    //5

//cin>>pt;

//fstrt.open(pt,ios::in|ios::out);

fstrt.open("E:\\新建文件夹\\新建文件夹\\l.txt",ios::in|ios::out);

if(!pt){ cerr<<"Can't open the file of fn.\n"; return; }

//while(fstrt.tellg()!=ptEnd){ fstrt.getline(fn,800);

//cout<<staf.staNum<<ends<<staf.staName<<ends<<staf.phoNum<<ends<<staf.num<<staf.staAddr<<endl; } //二进制的判断方法

do{ fstrt.getline(str,1000); cout<<str<<endl;  }while(!fstrt.eof());

fstr1.close(); fstr2.close(); fstr.close(); fstrt.close();

} */

C++->10.3.6.设有两个按升序排列的二进制文件a和b,将他们合并成一个新的升序二进制数据文件file。的更多相关文章

  1. 将两个列不同的DataTable合并成一个新的DataTable

    /// <summary>         /// 将两个列不同(结构不同)的DataTable合并成一个新的DataTable         /// </summary> ...

  2. 将两个数组相同index的value合并成一个新的value组成一个新的数组

    将两个数组相同index的value合并成一个新的value组成一个新的数组 前提: 这两个数组的长度相同 生成后的新数组长度也相同 返回值都是对象 把rows对象的key和value弄成两个数组, ...

  3. Java-Runoob-高级教程-实例-字符串:10. Java 实例 - 测试两个字符串区域是否相等-uncheck

    ylbtech-Java-Runoob-高级教程-实例-字符串:10. Java 实例 - 测试两个字符串区域是否相等 1.返回顶部 1. Java 实例 - 测试两个字符串区域是否相等  Java ...

  4. python之最强王者(10)———文件(File)、输入输出的基本操作

    1. Python 文件I/O 本章只讲述所有基本的的I/O函数,更多函数请参考Python标准文档. 2.打印到屏幕 最简单的输出方法是用print语句,你可以给它传递零个或多个用逗号隔开的表达式. ...

  5. ORA-01578: ORACLE 数据块损坏 (文件号 10, 块号 57896)ORA-01110: 数据文件 10: '/data/oradata/prod35.dbf'

    https://community.oracle.com/thread/3540795 概述 ------------- 数据库坏块(corruption) 的类型可以按照坏块所属对象的不同,分为用户 ...

  6. delphi 创建DBASE和FOXPRO两类DBF数据文件的差异

    delphi 创建DBASE和FOXPRO两类DBF数据文件的差异,主要有几点: 1.创建方法不同 DBASE的创建方法: Self.Table1.Close; Self.Table1.Active ...

  7. 如何定义让两个div横向排列

    方法一: 一般情况,默认的div是写一个换一行,那么如何定义两个div横向排列而不换行呢? div默认的display属性是block.所以每一个div都是新的一行,现在把display换成inlin ...

  8. 有两个序列A和B,A=(a1,a2,...,ak),B=(b1,b2,...,bk),A和B都按升序排列。对于1<=i,j<=k,求k个最小的(ai+bj)。要求算法尽量高效。

    有两个序列A和B,A=(a1,a2,...,ak),B=(b1,b2,...,bk),A和B都按升序排列.对于1<=i,j<=k,求k个最小的(ai+bj).要求算法尽量高效. int * ...

  9. python将两个数组合并成一个数组的两种方法的代码

    内容过程中,把写内容过程中常用的内容收藏起来,下面的资料是关于python将两个数组合并成一个数组的两种方法的内容,希望能对小伙伴们有帮助. c1 = ["Red","G ...

随机推荐

  1. 从数组中找到topK的元素(序号)

    问题: 在n个数中找出最大的k个数. 多次求min()或求max() 最简单的方法是对大小为k的数组进行n次求min计算(或者对大小为n的数组进行k次求max计算)最后能够找出最大k个数.复杂度是O( ...

  2. POJ_3627_贪心

    题目描述: 给你N个数和一个总和,要求求出最少个数的数相加大于等于这个总和. 思路: 很简单的贪心,先排序,从大到小加一次,比较一次,直到符合条件. 我用了优先队列,运行时间好像多了一倍= = #in ...

  3. Excel VBA: 自动生成巡检报表并通过邮件定时发送

    目录 环境说明逻辑结构效果说明及截图①.安装SecureCRT②. 自动巡检脚本③. 数据检索并FTP传送④. 安装Excel 2013⑤. 安装Serv-U⑥. 自动生成图表并邮件发送 环境说明 系 ...

  4. 文本相似性热度统计(python版)

    0. 写在前面 节后第一篇,疫情还没结束,黎明前的黑暗,中国加油,武汉加油,看了很多报道,发现只有中国人才会帮助中国人,谁说中国人一盘散沙?也许是年龄大了,看到全国各地的医务人员源源不断的告别家人去支 ...

  5. 《数据结构与算法分析-Java语言描述》 分享下载

    书籍信息 书名:<数据结构与算法分析-Java语言描述> 原作名:Data Structures and Algorithm Analysis in Java 作者: 韦斯 (Mark A ...

  6. Linux 工作机初始化操作

    # apt 依赖包安装 sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libs ...

  7. DOM - Document Object Model

    Document Object Model

  8. 20200223--python学习第15天

    今日内容 模块知识 内置模块 time/datatime/json/其他 内容回顾&作业题 重点知识点 构造字典和函数对应的关系,避免重复的if  else a = 1 b = 2 ----- ...

  9. Java中类锁和对象锁

    类锁 类锁 锁的其实是类的Class对象,类锁的代码写法是对类方法加synchronize,或者 synchronize(xx.class){} 对象锁 对象锁 锁的是类的实例对象,对象锁的形式有 对 ...

  10. Kvm 简介 安装 使用 桥接网络

    KVM 全称是 基于内核的虚拟机(Kernel-based Virtual Machine),它是一个 Linux 的一个内核模块,该内核模块使得 Linux 变成了一个 Hypervisor: 它由 ...