Version franēaise
Home     About     Download     Resources     Contact us    
Browse thread
printf & scanf oddity
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jean-Christophe Filliatre <filliatr@l...>
Subject: Re: [Caml-list] printf & scanf oddity

Basile STARYNKEVITCH writes:
 > 
 > I find the following quite strange:
 > 
 > % 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'".
 > 
 > Is it a bug, or did I misunderstood something?

I think this is the answer :-)

======================================================================
        Objective Caml version 3.08.3

# 1_;;
- : int = 1
# 1_2_3;;
- : int = 123
etc.
======================================================================

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...

-- 
Jean-Christophe Filliātre (http://www.lri.fr/~filliatr)