English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
printf and positional specifier
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2006-11-11 (20:56)
From: Anastasia Gornostaeva <ermine@e...>
Subject: Re: [Caml-list] printf and positional specifier
On Sat, Nov 11, 2006 at 08:35:56PM +0000, Peter Gregory wrote:

> ># printf "%2$d %1$s" "abc" 2;;
> >Bad conversion %$, at char number 0 in format string ``%2$d %1$s''

> I'm not sure that I understand your question.  I think to achieve what 
> you seem to be trying, you would simply write:
> # printf "%d %s" 2 "abc";;
> You just put the parameters in the order they came in the string.  Does 
> that help, it seems like perhaps you needed more than that.

>From documentation on Printf module:

   Conversion specifications have the following form:

   % [positional specifier] [flags] [width] [.precision] type

   The optional positional specifier consists of an integer followed by a $;
   the integer indicates which argument to use, the first argument being
   denoted by 1.