

#include "stdio.h"



int main()

{

int i = 0;

while (getchar() != EOF)

i++;

printf("%i

", i);

return 0;

}





{-# OPTIONS_GHC -fffi #-}



import Foreign.C.Types

import System.IO

import System.IO.Unsafe



foreign import ccall unsafe "stdio.h getchar" getchar :: IO CInt



main = print . length =<< getContents2



getContents2 :: IO String

getContents2 = do

c <- getchar

if c == (-1) then return [] else do

cs <- unsafeInterleaveIO getContents2

return (toEnum (fromIntegral c) : cs)

