caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* scanf %n may return 1 too much?
@ 2006-03-29  9:50 Hendrik Tews
  2006-03-29 10:03 ` [Caml-list] " Michael Wohlwend
  0 siblings, 1 reply; 2+ messages in thread
From: Hendrik Tews @ 2006-03-29  9:50 UTC (permalink / raw)
  To: caml-list

Dear all,

is the following really the intented behaviour?

# Scanf.sscanf " a" " %n" (fun n -> n);;
- : int = 2
# Scanf.sscanf " a" " a%n" (fun n -> n);;
- : int = 2

In the first one only one character is consumed, it should IMO
return 1. The second one consumes one character more than the
first one. So it should return one more than the first one.

How can I scan _precisely_ one space without the look ahead
behavior that the format " " apparently has? I guessed "% ", but
that raises an exception.

Bye,

Hendrik


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] scanf %n may return 1 too much?
  2006-03-29  9:50 scanf %n may return 1 too much? Hendrik Tews
@ 2006-03-29 10:03 ` Michael Wohlwend
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Wohlwend @ 2006-03-29 10:03 UTC (permalink / raw)
  To: caml-list

On Wednesday 29 March 2006 11:50, Hendrik Tews wrote:
>
> How can I scan _precisely_ one space without the look ahead
> behavior that the format " " apparently has? I guessed "% ", but
> that raises an exception.

sscanf "   a" "%1[ ]%n" (fun s n -> n);;

scans only one space...

 Michael



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-03-29 10:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-29  9:50 scanf %n may return 1 too much? Hendrik Tews
2006-03-29 10:03 ` [Caml-list] " Michael Wohlwend

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).