Sunday 15 May 2016

Haskell: getLine: Read line from standard input

getLine function read a line from the standard input device.

*Main> :t getLine
getLine :: IO String


Sample.hs
main = do
        putStrLn "Enter Your Name : "
        name <- getLine
        putStrLn ("Hello " ++  name)

$ ghc Sample.hs
$ ./Sample
Enter Your Name : 
Krishna
Hello Krishna


Previous                                                 Next                                                 Home

No comments:

Post a Comment