Sunday, 15 May 2016

Haskell: getChar: Read character

getChar functions reads a character from standard input device.

*Main> :t getChar
getChar :: IO Char


Sample.hs
main = do
        putStrLn "Enter (M) If you are male, else (F) "
        gender <- getChar
        putChar gender

$ ghc Sample.hs
Linking Sample ...
$ ./Sample
Enter (M) If you are male, else (F) 
M
M



Previous                                                 Next                                                 Home

No comments:

Post a Comment