From: Yan Jun Daisy Chen <yjc01@doc.ic.ac.uk>
To: caml-list@inria.fr
Subject: extract info from file
Date: Wed, 26 Jan 2005 15:37:51 +0000 (GMT) [thread overview]
Message-ID: <Pine.LNX.4.58.0501261533170.14221@quantum06.doc.ic.ac.uk> (raw)
I am trying to extract comments in a text file i.e. text between (* and
*). I declared a globle sting variable, buff to store them, and want to
store all the comments extracted in a list of string. Is the sting
variable size fixed once I initialise it?
The code I came up with is:
open Unix;;
let fileReader = openfile "student.cd" [O_RDONLY] 0o640;;
let buff = ref "file: ";;
let fileSize = (fstat fileReader).st_size;;
(*let fileSize = 50;;*)
let noOfChar = ref 0;;
let extract_comment () =
let openIndex = 0 in
noOfChar := read fileReader !buff openIndex fileSize;
(*print_string !buff; print_newline();
print_int !noOfChar; print_newline();;*)
let main () =
(*let fileContent = read fileReader !buff 0 5 in
print_int fileContent;*)
extract_comment();;
main ();;
Is there a simpler way to do this?
Thanks
Daisy
next reply other threads:[~2005-01-26 15:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-26 15:37 Yan Jun Daisy Chen [this message]
2005-01-26 19:14 ` [Caml-list] " Martin Jambon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.58.0501261533170.14221@quantum06.doc.ic.ac.uk \
--to=yjc01@doc.ic.ac.uk \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox