Haskell語言IO模塊中函數hPutChar的用法及代碼示例。
用法類型:
Handle -> Char -> IO ()
hPutCharhdl c將字符c寫入由hdl管理的文件或通道。如果為hdl啟用了緩衝,則可以緩衝字符。
示例1:
源碼:
import IO
import Char
main = do hdl <- openFile "/tmp/foo.txt" WriteMode
hPutChar hdl (chr 66)
hPutChar hdl ("ABCD" !! 0)
hClose hdl
hdl <- openFile "/tmp/foo.txt" ReadMode
x <- hGetContents hdl
putStr x
輸出:
BA
相關用法
注:本文由純淨天空篩選整理自 haskell hPutChar。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。