Notice
Recent Posts
Recent Comments
Link
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Archives
Today
Total
05-21 00:04
관리 메뉴

zyint's blog

[3] file descriptor redirection using dup2() 본문

예전글들

[3] file descriptor redirection using dup2()

진트­ 2008. 4. 17. 23:23

#include <io.h>
#include <stdio.h>
#include <fcntl.h> int main(int argc, char **argv)
{
    int nFD = open("C:\\redirect.txt", O_CREAT|O_RDWR, 0666);

    // 기존 stderr close     close(fileno(stderr));

    // stderr의 출력을 nFD로 redirection
    dup2(nFD, fileno(stderr));
    fprintf(stderr, "this is test\n");
    close(nFD);
    return 0;
}

 

원문

http://blog.daum.net/aswip/2773774

 

이 글은 스프링노트에서 작성되었습니다.

Comments