Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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 
in a toplevel:

open Printf;;

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

main () ;;

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?



It's fast, it's easy and it's free. Get MSN Messenger today!

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: