STDIN_FILENO與STDIN的區別


STDIN_FILENO與STDIN的區別:

  STDIN_FILENO:

  1).數據類型:int

  2).層次:系統級的API,是一個文件句柄,定義在<unistd.h>中。

  3).相應的函數:open(),close(),read(),write(),lseek()等系統級別的函數。

  SDTIN:

  1).數據類型:FILE *

  2).層次:c語言的提供的標准輸入流。c語言標准庫封裝系統函數實現。高級的輸入輸出函數。可在<stdio.h>中找到外部聲明。

  3).相應的函數:fopen(),fclose(),fread(),fwrite(),fseek()等c語言標准函數。

<unistd.h>

/* Standard file descriptors.  */
#define STDIN_FILENO    0       /* Standard input.  */
#define STDOUT_FILENO   1       /* Standard output.  */
#define STDERR_FILENO   2       /* Standard error output.  */

<stdio.h>

/* Standard streams.  */
extern struct _IO_FILE *stdin;          /* Standard input stream.  */
extern struct _IO_FILE *stdout;         /* Standard output stream.  */
extern struct _IO_FILE *stderr;         /* Standard error output stream.  */
/* C89/C99 say they're macros.  Make them happy.  */
#define stdin stdin
#define stdout stdout
#define stderr stderr

                                                      2012.8.8


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM