Version française
Home     About     Download     Resources     Contact us    
Browse thread
scanf %n may return 1 too much?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Hendrik Tews <tews@t...>
Subject: scanf %n may return 1 too much?
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