English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

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: 2007-03-22 (10:56)
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)