Read entire file: Difference between revisions
Content deleted Content added
m →{{header|OCaml}}: typo |
|||
Line 228:
There is no problem reading an entire file with the function <code>really_input</code> because this function is implemented appropriately with an internal loop, but it can only load files which size is equal or inferior to the maximum length of an ocaml string. This maximum size is available with the variable <code>Sys.max_string_length</code>. On 32 bit machines this size is about 16Mo.
To load bigger files several solutions exist, for example create a structure that
<lang ocaml>type big_string =
Line 245:
(bstr)</lang>
Then the length of the data can be get with <code>Bigarray.Array1.dim</code> instead of <code>String.length</code>, and we can access to a given char with the syntactic sugar <code>bstr.{i}</code> (instead of <code>str.[i]</code>) as
<lang ocaml>let () =
|