File input/output: Difference between revisions

added ocaml
(added ocaml)
Line 638:
 
The second argument "atomically:YES" write the content to a temporary file, and rename the temporary file to the destination file, replacing existing file.
 
=={{header|OCaml}}==
By line:
<ocaml>let ic = open_in "input.txt";;
let oc = open_out "output.txt";;
try
while true do
let s = input_line ic in
Printf.fprintf oc "%s\n" s
done
with End_of_file -> ();;</ocaml>
 
By character:
<ocaml>let ic = open_in "input.txt";;
let oc = open_out "output.txt";;
try
while true do
let c = input_char ic in
output_char oc c
done
with End_of_file -> ();;</ocaml>
 
=={{header|Perl}}==
Anonymous user