I am trying to have an exact match using
Scanf.sscanf below, i,e. I want
f to only execute when
"hello" exactly. But it doesn’t seem to work. Any ideas?
let print_hello i = let f = Printf.printf "hello\n" in Scanf.sscanf i "hello" f ;; utop # print_hello "hello";; hello - : unit = () utop # print_hello "hello_world";; hello - : unit = () utop # print_hello "world";; hello Exception: Stdlib.Scanf.Scan_failure "scanf: bad input at char number 0: looking for 'h', found 'w'".
Is there a way to specify
sscanf to have an exact match?