From: Virgile Prevosto <virgile.prevosto@m4x.org>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] printf & scanf oddity
Date: Fri, 27 Jan 2006 16:03:18 +0100 [thread overview]
Message-ID: <20060127160318.11667754@localhost.localdomain> (raw)
In-Reply-To: <20060127142622.GA8216@ours.starynkevitch.net>
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
prev parent reply other threads:[~2006-01-27 15:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-27 14:26 Basile STARYNKEVITCH
2006-01-27 14:57 ` [Caml-list] " Jean-Christophe Filliatre
2006-01-27 15:48 ` William D. Neumann
2006-01-27 15:03 ` Virgile Prevosto [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060127160318.11667754@localhost.localdomain \
--to=virgile.prevosto@m4x.org \
--cc=caml-list@yquem.inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox