A Collection of Code Snippets in as Many Programming Languages as Possible
This project is maintained by TheRenegadeCoder
Welcome to the File Input Output in OCaml page! Here, you'll find the source code for this program as well as a description of how the program works.
let filename = "output.txt"
let sample_text =
{|Some mundane sample text
Some sample text that is mundane
Another line of mundane sample text
|}
let () =
(try
Out_channel.with_open_text filename (fun oc ->
Out_channel.output_string oc sample_text)
with Sys_error msg ->
Printf.eprintf "Failed to write to '%s': %s\n" filename msg;
exit 1);
(try In_channel.with_open_text filename (fun ic -> In_channel.input_lines ic)
with Sys_error msg ->
Printf.eprintf "Failed to read from '%s': %s\n" filename msg;
exit 1)
|> List.iter print_endline
File Input Output in OCaml was written by:
If you see anything you'd like to change or update, please consider contributing.
No 'How to Implement the Solution' section available. Please consider contributing.
No 'How to Run the Solution' section available. Please consider contributing.