From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 385C0BBBB for ; Fri, 27 Jan 2006 16:03:10 +0100 (CET) Received: from localhost.localdomain (dhcp-rocq-166.inria.fr [128.93.62.166]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k0RF39Fr022851 for ; Fri, 27 Jan 2006 16:03:09 +0100 Date: Fri, 27 Jan 2006 16:03:18 +0100 From: Virgile Prevosto To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] printf & scanf oddity Message-ID: <20060127160318.11667754@localhost.localdomain> In-Reply-To: <20060127142622.GA8216@ours.starynkevitch.net> References: <20060127142622.GA8216@ours.starynkevitch.net> X-Mailer: Sylpheed-Claws 1.9.100 (GTK+ 2.8.10; i486-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Miltered: at concorde with ID 43DA362D.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 printf:01 scanf:01 basile:01 ocaml:01 printf:01 sprintf:01 scanf:01 sscanf:01 char:01 ocaml:01 syntax:01 literals:01 sscanf:01 tutto:98 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO autolearn=disabled version=3.0.3 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