Browse thread
open_file
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Karl Zilles <zilles@1...> |
| Subject: | Re: [Caml-list] open_file |
yjc01@doc.ic.ac.uk wrote: > The code I came up with is as follows: I forgot to add, there is no reason to use a reference for buff: > > open Unix;; > > let file_reader = openfile "sudent.cd" [O_RDONLY] 0o640;; > let buff = ref "empty";; let buff = "empty";; > > let main () = > let file_content = read file_reader !buff 1 5 in let file_content = read file_reader buff 0 5 in > print_int file_content; > print_string !buff;; print_string buff;; > main (); This is because you are actually writing directly on the string, so there is no need for indirection.