[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Virgile Prevosto <virgile.prevosto@m...> |
| Subject: | Re: [Caml-list] printf & scanf oddity |
Hello, Le ven 27 jan 2006 15:26:22 CET, Basile STARYNKEVITCH a écrit: > % ocaml > Objective Caml version 3.09.1 > > # Printf.sprintf "_a%d_f%d" 1 2;; > - : string = "_a1_f2" > # Scanf.sscanf "_a1_f2" "_a%d_f%d" (fun x y -> x,y);; > Exception: > Scanf.Scan_failure > "scanf: bad input at char number 5: looking for '_', found 'f'". > I'd say that it comes from the fact that in ocaml syntax '_' can be used to separate blocks of numerals in integer and float literals: the first integer read by sscanf is "1_" and not "1". There might be a workaround by using %[0-9] instead of %d (and int_of_string in the final computation of course). -- E tutto per oggi, a la prossima volta Virgile