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: | Oliver Bandel <oliver@f...> |
| Subject: | Re: [Caml-list] open_file |
On Tue, Jan 25, 2005 at 02:43:07PM -0800, Karl Zilles wrote: > (forgot to copy the list, originally) > > yjc01@doc.ic.ac.uk wrote: > > > 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. > > > My guess is that you aren't including the unix library on your compile > command line: > > ocamlc [other_options] unix.cma [other_files] > ocamlopt [other_options] unix.cmxa [other_files] > OH,awell, the error was during compilation? Well, I have overlooked this. It's *always* good to have more informations on the kind of errors. When the compilation-errors are gone, I'm sure there will be many errors possivle during execution.... [...] > > print_int file_content; > > print_string !buff;; > > main (); > > I couldn't work out what went wrong. Can anyone help?!! It couldn't work, because there is only one ";" at the last line... > > Also, using the Unix libray is probably overkill for this kind of thing. Seems so. > You might want to switch to the Pervasives library, which is > automatically included with all ocaml programs. Yes - that's a good high-level handling of I/O. It's buffered and a quite good thing! :) Ciao, Oliver