Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] input_line ... have i gone mad?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Nicolas Wu <nickwu2000@h...>
Subject: [Caml-list] input_line ... have i gone mad?
Hey all, i'm trying to write a very simple program using input_line to grab
input from stdin ... but it is going horribly wrong! try putting the 
following
in a toplevel:

<<cut>>
open Printf;;

let main () =
try
printf "start";
while true do
  printf "just before"; flush stdout;
  let line = input_line stdin in
  printf "print the line %s" line
done
with End_of_file ->
printf "should exit";;

main () ;;
<<cut>>

on my machine, it works fine, but never reaches the "should exit" line-
it seems like the End_of_file exception is never thrown - this is the same
even if i use read_line () instead of input_line.... what am i doing wrong?

thanks!

nick

_________________________________________________________________
It's fast, it's easy and it's free. Get MSN Messenger today! 
http://www.msn.co.uk/messenger

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners