java是什么 C語言如何重定向輸入和輸出?
C語言如何重定向輸入和輸出?在C語言中,freeopen可用于重定向輸入和輸出。C語言的標(biāo)準(zhǔn)輸入輸出是stdin和stdout。這兩個(gè)變量的類型是file*,也就是說,標(biāo)準(zhǔn)輸入輸出操作的本質(zhì)是file
C語言如何重定向輸入和輸出?
在C語言中,freeopen可用于重定向輸入和輸出。C語言的標(biāo)準(zhǔn)輸入輸出是stdin和stdout。這兩個(gè)變量的類型是file*,也就是說,標(biāo)準(zhǔn)輸入輸出操作的本質(zhì)是file操作。當(dāng)需要重定向時(shí),可以調(diào)用stdin=freeopen()數(shù)據(jù)輸入“,”r“,stdin)stdout=freopen(”數(shù)據(jù)輸出,W,stdout)將標(biāo)準(zhǔn)輸入重定向到數(shù)據(jù)輸入將標(biāo)準(zhǔn)輸出重定向到數(shù)據(jù)輸出. 調(diào)用此函數(shù)時(shí),需要引用頭文件stdio。H.
如何將標(biāo)準(zhǔn)輸入輸出的內(nèi)容重定向到文件中?
Command> filenameredirect standard output to a new file Command> filenameredirect standard output to a file(append)Command
1> fielname redirect standard output to a file Command> filename2>&1 redirect standard output and standard error to a file Command
2> filename Redirecting文件的標(biāo)準(zhǔn)錯(cuò)誤命令2>>文件名將標(biāo)準(zhǔn)輸出重定向到文件(追加)命令>>文件名2>&;amp1將標(biāo)準(zhǔn)輸出和標(biāo)準(zhǔn)錯(cuò)誤重定向到文件(追加)命令filename2將命令作為標(biāo)準(zhǔn)輸入,filename2作為標(biāo)準(zhǔn)輸出&Ampm將標(biāo)準(zhǔn)輸出重定向到文件描述符M。標(biāo)準(zhǔn)輸入是鍵盤,標(biāo)準(zhǔn)輸出是顯示器。所謂重定向就是通過改變標(biāo)準(zhǔn)輸入和標(biāo)準(zhǔn)輸出來實(shí)現(xiàn)一些特殊的功能。<和>是用于輸入重定向和輸出重定向的保持器。