dup

dup

dup它有多種意義,包括Linux c 函式、C語言函式DUP、彙編指令、化學物質DUP。

Linux c 函式

#include<unistd.h>

int dup(int fd);

int dup2(int fd1,int fd2);

兩個均為複製一個現存的檔案的描述

兩個函式的返回:若成功為新的檔案描述,若出錯為-1;

由dup返回的新檔案描述符一定是當前可用檔案描述中的最小數值。用dup2則可以用fd2參數指定新的描述符數值。如果fd2已經打開,則先關閉。若fd1=fd2,則dup2返回fd2,而不關閉它。通常使用這兩個系統調用來重定向一個打開的檔案描述符。

C語言函式DUP

函式簡介

函式名: _dup

功 能: 複製一個檔案句柄

用 法: int _dup(int handle);

相關函式:_dup2、fdopen、freopen、_mbsdup、_wcsdup、_strdup

程式示例

#include <string.h>

#include <stdio.h>

#include <conio.h>

#include <io.h>

void flush(FILE *stream);

int main(void)

{

FILE *fp;

char msg[] = "This is a test";

/* create a file */

fp = fopen("DUMMY.FIL", "w");

/* write some data to the file */

fwrite(msg, strlen(msg), 1, fp);

clrscr();

printf("Press any key to flush \

DUMMY.FIL:");

getch();

/* flush the data to DUMMY.FIL without

closing it */

flush(fp);

printf("\nFile was flushed, Press any \

key to quit:");

getch();

return 0;

}

void flush(FILE *stream)

{

int duphandle;

/* flush TC's internal buffer */

fflush(stream);

/* make a duplicate file handle */

duphandle = dup(fileno(stream));

/* close the duplicate handle to flush the

DOS buffer */

close(duphandle);

}

彙編指令

dup 在彙編中是一條偽指令,用來重複初始化數據

用法舉例:

str1 db 10 dup ('!@#') ;這就是十個!@#

格式:db 重複的次數 dup (重複的內容)

化學物質DUP

DUP是1,2-苯二甲酸二正十一酯,不溶於水,主要是作為增塑劑來使用的,溶於酯類。

相關詞條

相關搜尋

熱門詞條

聯絡我們