首頁(yè) 考試吧論壇 Exam8視線(xiàn) 考試商城 網(wǎng)絡(luò)課程 模擬考試 考友錄 實(shí)用文檔 求職招聘 論文下載
2011中考 | 2011高考 | 2012考研 | 考研培訓(xùn) | 在職研 | 自學(xué)考試 | 成人高考 | 法律碩士 | MBA考試
MPA考試 | 中科院
四六級(jí) | 職稱(chēng)英語(yǔ) | 商務(wù)英語(yǔ) | 公共英語(yǔ) | 托福 | 雅思 | 專(zhuān)四專(zhuān)八 | 口譯筆譯 | 博思 | GRE GMAT
新概念英語(yǔ) | 成人英語(yǔ)三級(jí) | 申碩英語(yǔ) | 攻碩英語(yǔ) | 職稱(chēng)日語(yǔ) | 日語(yǔ)學(xué)習(xí) | 法語(yǔ) | 德語(yǔ) | 韓語(yǔ)
計(jì)算機(jī)等級(jí)考試 | 軟件水平考試 | 職稱(chēng)計(jì)算機(jī) | 微軟認(rèn)證 | 思科認(rèn)證 | Oracle認(rèn)證 | Linux認(rèn)證
華為認(rèn)證 | Java認(rèn)證
公務(wù)員 | 報(bào)關(guān)員 | 銀行從業(yè)資格 | 證券從業(yè)資格 | 期貨從業(yè)資格 | 司法考試 | 法律顧問(wèn) | 導(dǎo)游資格
報(bào)檢員 | 教師資格 | 社會(huì)工作者 | 外銷(xiāo)員 | 國(guó)際商務(wù)師 | 跟單員 | 單證員 | 物流師 | 價(jià)格鑒證師
人力資源 | 管理咨詢(xún)師考試 | 秘書(shū)資格 | 心理咨詢(xún)師考試 | 出版專(zhuān)業(yè)資格 | 廣告師職業(yè)水平
駕駛員 | 網(wǎng)絡(luò)編輯
衛(wèi)生資格 | 執(zhí)業(yè)醫(yī)師 | 執(zhí)業(yè)藥師 | 執(zhí)業(yè)護(hù)士
會(huì)計(jì)從業(yè)資格考試會(huì)計(jì)證) | 經(jīng)濟(jì)師 | 會(huì)計(jì)職稱(chēng) | 注冊(cè)會(huì)計(jì)師 | 審計(jì)師 | 注冊(cè)稅務(wù)師
注冊(cè)資產(chǎn)評(píng)估師 | 高級(jí)會(huì)計(jì)師 | ACCA | 統(tǒng)計(jì)師 | 精算師 | 理財(cái)規(guī)劃師 | 國(guó)際內(nèi)審師
一級(jí)建造師 | 二級(jí)建造師 | 造價(jià)工程師 | 造價(jià)員 | 咨詢(xún)工程師 | 監(jiān)理工程師 | 安全工程師
質(zhì)量工程師 | 物業(yè)管理師 | 招標(biāo)師 | 結(jié)構(gòu)工程師 | 建筑師 | 房地產(chǎn)估價(jià)師 | 土地估價(jià)師 | 巖土師
設(shè)備監(jiān)理師 | 房地產(chǎn)經(jīng)紀(jì)人 | 投資項(xiàng)目管理師 | 土地登記代理人 | 環(huán)境影響評(píng)價(jià)師 | 環(huán)保工程師
城市規(guī)劃師 | 公路監(jiān)理師 | 公路造價(jià)師 | 安全評(píng)價(jià)師 | 電氣工程師 | 注冊(cè)測(cè)繪師 | 注冊(cè)計(jì)量師
繽紛校園 | 實(shí)用文檔 | 英語(yǔ)學(xué)習(xí) | 作文大全 | 求職招聘 | 論文下載 | 訪(fǎng)談 | 游戲

C語(yǔ)言中標(biāo)準(zhǔn)輸入流、標(biāo)準(zhǔn)輸出流、標(biāo)準(zhǔn)錯(cuò)誤輸出流

  在Linux中,所有對(duì)設(shè)備和文件的操作都使用文件描述符來(lái)進(jìn)行。

  Linux中一個(gè)進(jìn)程啟動(dòng)時(shí),都會(huì)打開(kāi)3個(gè)文件:標(biāo)準(zhǔn)輸入、標(biāo)準(zhǔn)輸出和標(biāo)準(zhǔn)出錯(cuò)處理。這三個(gè)文件分別對(duì)應(yīng)文件描述符0、1、2。

  在C語(yǔ)言中,在程序開(kāi)始運(yùn)行時(shí),系統(tǒng)自動(dòng)打開(kāi)3個(gè)標(biāo)準(zhǔn)文件:標(biāo)準(zhǔn)輸入、標(biāo)準(zhǔn)輸出、標(biāo)準(zhǔn)出錯(cuò)輸出。通常這3個(gè)文件都與終端相聯(lián)系。因此,以前我們所用到的從終端輸入或輸出都不需要打開(kāi)終端文件。系統(tǒng)自定義了3個(gè)文件指針 stdin、stdout、stderr,分別指向終端輸入、終端輸出和標(biāo)準(zhǔn)出錯(cuò)輸出(也從終端輸出)。

  標(biāo)準(zhǔn)輸入流:stdin

  標(biāo)準(zhǔn)輸出流:stdout

  標(biāo)準(zhǔn)錯(cuò)誤輸出流:stderr

  stdin

  objectFILE * stdin;

  Standard input stream

  The standard input stream is the default source of data for applications. It is usually directed to the input device of the standard console (generally, a keyboard).

  stdin can be used as an argument for any function that expects an input stream as one of its parameters, like fgets or fscanf.

  Although it is generally safe to assume that the source of data for stdin is going to be a keyboard, bear in mind that this may not be the case even in regular console systems, since stdin can be redirected at the operating system level. For example, many systems, among them DOS/Windows and most UNIX shells, support the following command syntax:

  myapplication < example.txt

  to use the content of the file example.txt as the primary source of data for myapplication instead of the console keyboard.

  It is also possible to redirect stdin to some other source of data from within a program using the freopen function.

  stdout

  objectFILE * stdout;

  Standard output stream

  The standard output stream is the default destination of regular output for applications. It is usually directed to the output device of the standard console (generally, the screen).

  stdout can be used as an argument for any function that expects an output stream as one of its parameters, like fputs or fprintf.

  Although it is generally safe to assume that the default destination for stdout is going to be the screen, bear in mind that this may not be the case even in regular console systems, since stdout can be redirected at the operating system level. For example, many systems, among them DOS/Windows and most UNIX shells, support the following command syntax:

  myapplication > example.txt

  to redirect the output of myapplication to the file example.txt instead of the screen.

  It is also possible to redirect stdout to some other source of data from within a program using the freopen function.

  相關(guān)推薦:計(jì)算機(jī)等考二級(jí)C:C中如何顯示*.bmp文件
       2010年上半年全國(guó)計(jì)算機(jī)等級(jí)考試報(bào)名匯總
       2010年上半年計(jì)算機(jī)等級(jí)考試時(shí)間:3月27日-31日
文章搜索
版權(quán)聲明:如果計(jì)算機(jī)等級(jí)考試網(wǎng)所轉(zhuǎn)載內(nèi)容不慎侵犯了您的權(quán)益,請(qǐng)與我們聯(lián)系800@exam8.com,我們將會(huì)及時(shí)處理。如轉(zhuǎn)載本計(jì)算機(jī)等級(jí)考試網(wǎng)內(nèi)容,請(qǐng)注明出處。