NO_REDIR.C
资源名称:C.rar [点击查看]
上传用户:qq5388545
上传日期:2022-07-04
资源大小:29849k
文件大小:1k
源码类别:
界面编程
开发平台:
C/C++
- #include <stdio.h>
- #include <dos.h>
- void main (void)
- {
- union REGS inregs, outregs;
- // check the stdin handle first
- inregs.x.ax = 0x4400;
- inregs.x.bx = 0; // stdin is handle 0
- intdos (&inregs, &outregs);
- if ((outregs.x.dx & 1) && (outregs.x.dx & 128))
- fprintf (stderr, "stdin has not been redirectedn");
- else
- fprintf (stderr, "stdin is redirectedn");
- // Now check stdout
- inregs.x.ax = 0x4400;
- inregs.x.bx = 1; // stdout is handle 1
- intdos (&inregs, &outregs);
- if ((outregs.x.dx & 2) && (outregs.x.dx & 128))
- fprintf (stderr, "stdout has not been redirectedn");
- else
- fprintf (stderr, "stdout is redirectedn");
- }