Linux c 函式
#include
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);
程式示例
#include
#include
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 withoutclosing 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 theDOS buffer */close(duphandle);}
彙編指令
用法舉例:
str1 db 10 dup ('!@#') ;這就是十個!@#
格式:db 重複的次數 dup (重複的內容)
化學物質DUP
DUP是1,2-苯二甲酸二正十一酯,不溶於水,主要是作為增塑劑來使用的,溶於酯類。