Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] sscanf help
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-04-20 (09:57)
From: Pierre Weis <pierre.weis@i...>
Subject: Re: [Caml-list] sscanf help
> Hello,
> I am having hardtime dealing with sscanf and fscanf fucntion. I am actually 
> converting code from C to OCAML. The functions uses multiple sscanf 
> fucntions. I have no clue how to deal with this. Can anyone please help me 
> out?


The Caml's sscanf and fscanf functions are fully documented and are
easier to use and much more powerful than their C counterparts; so,
unless the documentation is unclear (and then please report it to me),
I think your problem is more related to C programming than to some
O'Caml specific scanf difficulties.

In effect, the C function you gave and have to translate to Caml looks
extremely stateful and imperative style in spirit, while our
programming language and its scanf facility are functional (or
stateless). So, even if it is possible to mimic the C program in Caml,
the resulting program is likely to be inelegant and contrived by an
unatural one-to-one translation.

In conclusion, you had better to understand the specification of the C
parsing function and then reimplement it into a (simpler) functional
Caml program.

Hope this helps,

Pierre Weis

INRIA, Projet Cristal,,

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: