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
3.10 changes for scanf
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: micha <micha-1@f...>
Subject: 3.10 changes for scanf

I have a file with one int per line and when reading it with:

            let x = (Scanf.fscanf log "%d" (fun n -> n)) in
            let y = (Scanf.fscanf log "%d" (fun n -> n)) in
            let w = (Scanf.fscanf log "%d" (fun n -> n)) in
            let h = (Scanf.fscanf log "%d" (fun n -> n)) in

it works in 3.09, but 3.10 fails with: 
Exception: Scanf.Scan_failure "scanf: bad input at char number 1: \n"

so I must change the format string to " %d " (note the spaces around
%d) to eat the newline too, is this a desired change?
( the c version reads the numbers with just "%d", I'm not sure what's
the correct behavior)