⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dup.c

📁 C语言常用的程序900例
💻 C
字号:
#include <stdio.h>
#include <fcntl.h>
#include <io.h>
#include <sys\stat.h>

void main(void)
 {
   int handle;
   int duplicate_handle;

   char title[] = "Jamsa's 1001 C/C++ Tips!";
   char section[] = "Files";

   if ((handle = open("OUTPUT.TST", O_WRONLY | O_CREAT, 
        S_IWRITE)) == -1)
     printf("Error opening OUTPUT.TST\n");
   else
    {
      if ((duplicate_handle = dup(handle)) == -1)
        printf("Error duplicating handle\n");
      else
        {
          write(handle, title, sizeof(title));
          close(duplicate_handle);  // Flush the buffer
          write(handle, section, sizeof(section));
          close(handle);
        }
    }
 }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -