From 4ce305a938ad30fb6176525044ad138f1f8ce175 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Qiang-=E5=BF=97?= <3184528452@qq.com> Date: Sat, 28 Oct 2023 16:22:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- combine.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 combine.cpp diff --git a/combine.cpp b/combine.cpp new file mode 100644 index 0000000..aa98292 --- /dev/null +++ b/combine.cpp @@ -0,0 +1,22 @@ +#include +#include +#include +#include +#define LEN 512 +int main(int argc, char** argv) { + int f1, f2, f3, n = 0; + char buf[520], ch = '\n'; + f1 = open(argv[1], O_RDWR); + f2 = open(argv[2], O_RDWR); + f3 = open(argv[3], O_CREAT | O_RDWR); + while ((n = read(f1, buf, LEN)) > 0) + write(f3, buf, n); + write(f3, &ch, 1); + while ((n = read(f2, buf, LEN)) > 0) + write(f3, buf, n); + close(f1); + close(f2); + close(f3); + return 0; +} +