stdout 中文man頁面

2021-01-11 51cto

NAME

stdin stdout stderr - 標準 I/O 流

SYNOPSIS 總覽

Fd #include <stdio.h> Fd extern FILE *stdin; Fd extern FILE *stdout; Fd extern FILE *stderr;

DESCRIPTION 描述

通常,每個 Unix 程序在啟動時都會打開三個流,一個用於輸入,一個用於輸出,一個用於列印診斷或錯誤消息。典型的,他們被連接到用戶的終端 (參見 tty(4)) 但是也有可能指向文件或是其他設備,取決於父進程選擇設置了什麼 (參見 sh(1) 的重定向 (``Redirection'') 章節。)

輸入流被稱為 ``standard input''; 輸出流被稱為 ``standard output''; 錯誤流被稱為 ``standard error''。這些名詞通常簡寫為符號,用於引用這些文件,它們是 stdin stdout 和 stderr

這些符號中,每一個都是 stdio(3) 中的一個宏,類型是指向 FILE 的指針,可以用於類似 fprintf(3) 或 fread(3) 等函數中。

由於 FILE 是一個對 Unix 文件描述符加以緩衝的包裝,下層的文件也可以使用原始的 Unix 文件接口來存取。也就是,類似 read(2) 和 lseek(2) 的函數。與流 stdin stdout 和 stderr 關聯的整數形式的文件描述符分別是 0,1 還有 2。預處理器符號 STDIN_FILENO,STDOUT_FILENO 和 STDERR_FILENO 分別以它們為值,定義在 <unistd.h> 中。

注意混合使用 FILE 和原始的文件描述符可能帶來不可預料的結果,一般應當避免。(對於喜歡追根問底的人:POSIX.1 規範的 8.2.3 節詳細地描述了這樣的混合使用怎樣才能不出錯。) 一個簡單的規則是,文件描述符由內核控制,而 stdio 僅僅是一個庫。它的意思是,例如當調用 exec 之後,子進程可以繼承所有打開的文件描述符,但是任何原有的流都不可再存取了。

由於符號 stdin stdout 和 stderr 被指定為宏,為它們賦值將導致不可移植。利用庫函數 freopen(3) ,標準流可以用來指向不同的文件。引進這個函數專門用來為 stdin stdout 和 stderr 重新賦值。標準流在調用 exit(3) 和程序正常中止時被關閉。

SEE ALSO 參見

sh(1), csh(1), open(2), fopen(3), stdio(3) 

NAME

stdin stdout stderr - standard I/O streams

SYNOPSIS

Fd #include <stdio.h> Fd extern FILE *stdin; Fd extern FILE *stdout; Fd extern FILE *stderr;

DESCRIPTION

Under normal circumstances every Unix program has three streams opened for it when it starts up, one for input, one for output, and one for printing diagnostic or error messages. These are typically attached to the user's terminal (see tty(4)) but might instead refer to files or other devices, depending on what the parent process chose to set up. (See also the ``Redirection'' section of sh(1).)

The input stream is referred to as ``standard input''; the output stream is referred to as ``standard output''; and the error stream is referred to as ``standard error''. These terms are abbreviated to form the symbols used to refer to these files, namely stdin stdout and stderr

Each of these symbols is a stdio(3) macro of type pointer to FILE, and can be used with functions like fprintf(3) or fread(3).

Since FILEs are a buffering wrapper around Unix file descriptors, the same underlying files may also be accessed using the raw Unix file interface, that is, the functions like read(2) and lseek(2). The integer file descriptors associated with the streams stdin stdout and stderr are 0, 1, and 2, respectively. The preprocessor symbols STDIN_FILENO, STDOUT_FILENO, and STDERR_FILENO are defined with these values in <unistd.h>.

Note that mixing use of FILEs and raw file descriptors can produce unexpected results and should generally be avoided. (For the masochistic among you: POSIX.1, section 8.2.3, describes in detail how this interaction is supposed to work.) A general rule is that file descriptors are handled in the kernel, while stdio is just a library. This means for example, that after an exec, the child inherits all open file descriptors, but all old streams have become inaccessible.

Since the symbols stdin stdout and stderr are specified to be macros, assigning to them is non-portable. The standard streams can be made to refer to different files with help of the library function freopen(3), specially introduced to make it possible to reassign stdin stdout and stderr The standard streams are closed by a call to exit(3) and by normal program termination.

SEE ALSO

sh(1), csh(1), open(2), fopen(3), stdio(3) 

【責任編輯:

韓亞珊

TEL:(010)68476606】

點讚 0

相關焦點

  • CLOSE 中文man頁面
    CLOSE 中文man頁面 CLOSE 釋放和一個遊標關聯的資源。 一個遊標關閉後,不允許對其再做任何操作。一個不再使用的遊標應該關閉掉。
  • DROP INDEX 中文man頁面
    DROP INDEX 中文man頁面 DROP INDEX 從資料庫中刪除一個現存的索引。 要執行這個命令,你必須是索引的所有者。
  • START TRANSACTION 中文man頁面
    START TRANSACTION 中文man頁面 這條命令開始一個新的事務。如果聲明了隔離級別或者讀寫模式, 那麼新事務就使用這個特性,如同執行了 SET TRANSACTION [set_transaction(7)] 一樣。
  • setvbuf 中文man頁面
    如果流指向一個終端 (通常 stdout 都是這樣),那麼它是行緩衝的。標準錯誤流 stderr 默認總是無緩衝的。函數 setvbuf 可以用在任何打開的流上,改變它的緩衝。If a stream refers to a terminal (as stdout normally does) it is line buffered. The standard error stream stderr is always unbuffered by default.
  • pppd 中文man頁面
    The default is for pppd to send log messages to stdout (file descriptor 1), unless the serial port is already open on stdout.
  • modinfo 中文man頁面
  • grep 中文man頁面
  • CREATE CONVERSION 中文man頁面
  • eMule-Project站點增加簡體中文頁面
    感謝阿pp的投遞:簡體中文作業系統用戶上eMule-project網站會被自動轉到簡體用戶頁面了.eMule-project
  • 首發中文?SE《復聯》遊戲新作上線中文倒計時頁面 - 3DMGAME
    而今日我們可以發現Square Enix赫然上線了遊戲的中文網站,並顯眼的給出了遊戲公布的倒計時,且該頁面支持簡體中文和繁體中文切換,這是否意味著此次的《漫威復仇者聯盟》官中已經給安排上了?
  • 模擬建造新遊《叢林之屋》上架Steam頁面 支持中文
    模擬建造新遊《叢林之屋》上架Steam頁面 支持中文 時間:2020-07-03 09:05:33 來源:Steam
  • 《賽博朋克2077》三張4K截圖 中文官網頁面更新
    《賽博朋克2077》三張4K截圖 中文官網頁面更新 《賽博朋克2077》三張4K截圖 中文官網頁面更新
  • No man is an island是什麼意思?
    No man is an island的英語能力口語訓練No man is an island是什麼意思?我們還是先用英語No man is an island做「把學過的英語用起來」「見英語說英語」的能力訓練吧。我不要你見英語No man is an island能「說」中文的能力,也不需要你今天學了英語No man is an island明天就有機會跟人說英語No man is an island(沒有人是座孤島)。
  • 首批火星地形地貌中文推薦譯名 中國天文學會官網可視化頁面入口地址
    首頁 > 動態 > 關鍵詞 > 火星最新資訊 > 正文 首批火星地形地貌中文推薦譯名 中國天文學會官網可視化頁面入口地址
  • 把英語讀成英語的能力:a man of importance什麼意思?
    把英語讀成英語的能力:a man of importance什麼意思?一、什麼是「英語閱讀」英能力訓練?這個能力是什麼?我們說的這個能力就是你閱讀時「對著英語說英語」的能力,而不是「對著英語說中文」。這個不叫做英語閱讀,這個叫做中文閱讀。二、注意英語詞彙裡有一種詞性轉換的現象。
  • 美國人說的I'm a man of my word是什麼意思?
    美國人說的I'm a man of my word是什麼意思?我們所有的「英語閱讀」,都可以歸結為回答一個問題:你的「英語閱讀」指的就是用中文「讀懂」英語,用中文意思去「懂得」英語在說什麼嗎?一、下面的英語a man of word時,你是讀」成中文,還是英語?1. Bob, I'm a man of my word.
  • 英語口語:one man's meat is another's poison
    英語口語:one man's meat is another's poison1) 把英語one man's meat is another's poison翻譯成中文理解,是「學習英語」:你終於「用」中文懂得英語one man's meat is another's poison
  • creeper aww man是什麼梗 Creeper接龍歌曲梗出處及中文意思
    creeper aww man是什麼梗?就好似接龍一樣,說出「creeper」,自然而然會說「aww man」,這是為什麼呢,大家都不知道是什麼意思,下面小編就為大家詳細介紹一下吧。Aw man,這是連起來的一句話,說了Creeper,就會有人不自覺地說出Aw man,就是好玩,一種樂趣。  由於《我的世界》裡的「creeper」梗火起來的,很多網友在抖音、貼吧、論壇、微博等自娛自樂著。  就類似與有人說了「窩窩頭,一塊錢四個」,就會有人不自覺地說出「嘿嘿」一樣的意思。
  • 關於「Man」的俚語
    2. man of letters 文人、作家、學者例句:Shakespeare was perhaps Britain's greatest man of letters.莎士比亞或許可以算是英國最偉大的作家。