caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* open_file
@ 2005-01-25 22:19 yjc01
  2005-01-25 22:43 ` [Caml-list] open_file Karl Zilles
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: yjc01 @ 2005-01-25 22:19 UTC (permalink / raw)
  To: caml-list

I tried to read in a text file and extract the string between (* and *) into a 
variable, buff, by using the openfile and read functions in Unix module. But 
get an error on compilation.

The code I came up with is as follows: 

open Unix;;

let file_reader = openfile "sudent.cd" [O_RDONLY] 0o640;;
let buff = ref "empty";;

let main () =
  let file_content = read file_reader !buff 1 5 in
  print_int file_content;
  print_string !buff;;
main ();
I couldn't work out what went wrong. Can anyone help?!!

Daisy


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-01-26 15:50 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-25 22:19 open_file yjc01
2005-01-25 22:43 ` [Caml-list] open_file Karl Zilles
2005-01-25 22:58   ` Oliver Bandel
2005-01-26 14:41   ` [Caml-list] read file Yan Jun Daisy Chen
2005-01-26 15:50     ` Oliver Bandel
2005-01-25 22:54 ` [Caml-list] open_file Karl Zilles
2005-01-26 10:16   ` Marcin 'Qrczak' Kowalczyk
2005-01-25 22:54 ` Oliver Bandel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).