I do not understand why this is the case:
Printf.sprintf "%08s" "s" = Printf.sprintf "%8s" "s"
- : bool = true
In other words, I would expect:
Printf.sprintf "%08s" "s"
- : string = "0000000s"
and not the actual result:
- : string = " s"
could someone please clarify why this is so?
From the documentation of
printf, you can see that the0flag does not apply to%s.(Emphasis is mine.)
Notice that, in C, it leads to an undefined behavior.