[4] dup2
dup2
기능 |
파일핸들(oldhandle)을 존재하는 파일핸들(newhandle)로 복사한다. |
||||||||||
문법 |
#include<io.h> |
||||||||||
|
|||||||||||
주석 |
dup2는 유닉스 시스템 III하에서는 실행되지 않는다. |
||||||||||
반환값 |
새로운 파일 핸들이 성공적으로 복사 되었으면 0을 , 그렇지 않은 경우는 -1을 반환한다. 에러가 발생한 경우에는 전역변수 errno를 다음 중 하나로 설정한다. |
||||||||||
참조 |
_close, close, _creat, creat, cratnew, creattemp, dup, fopen, _open, open |
||||||||||
예제 |
#include <sys\stat.h> int main(void) int nul, oldstdout; /* create a file */ /* create a duplicate handle for standard output */ /* close the handle for DUMMY.FIL */ /* will be redirected into DUMMY.FIL */ /* restore original standard output handle */ /* close duplicate handle for STDOUT */ return 0; |
원문
http://www.cworldlab.com/CandCplus/clibrary/dup2.htm
이 글은 스프링노트에서 작성되었습니다.