Browse thread
printf & scanf oddity
-
Basile STARYNKEVITCH
-
Jean-Christophe Filliatre
- William D. Neumann
- Virgile Prevosto
-
Jean-Christophe Filliatre
[
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: | William D. Neumann <wneumann@c...> |
| Subject: | Re: [Caml-list] printf & scanf oddity |
On Fri, 27 Jan 2006, Jean-Christophe Filliatre wrote:
> See "integer literals" in the manual :
> http://caml.inria.fr/pub/docs/manual-ocaml/manual009.html
>
> But I agree with you: this is wierd and almost a bug...
Even more clearly, see the Scanf module documentation. From page 349 of
the 3.09 manual:
*in addition to relevant digits, _ characters may appear inside numbers
(this is reminiscent to the usual Caml conventions). If stricter scanning
is desired, use the range conversion facility instead of the number
conversions.
So, for example, this works:
# Scanf.sscanf "_a14_f2" "_a%[0-9]_f%[0-9]" (fun x y -> x,y);;
- : string * string = ("14", "2")
Though the return type is string, not int, so you'd need to convert them
if you want ints...
William D. Neumann
---
"There's just so many extra children, we could just feed the
children to these tigers. We don't need them, we're not doing
anything with them.
Tigers are noble and sleek; children are loud and messy."
-- Neko Case
Life is unfair. Kill yourself or get over it.
-- Black Box Recorder