我正在尝试从文件中读取字符,然后在文件中将字符和字符前后一起写入。例如..
inputfile中: 你好 输出文件: h l l l o
以下是逐行阅读的代码。
fun copyTextFile(infile: string, outfile: string) =
let
val ins = TextIO.openIn infile
val outs = TextIO.openOut outfile
fun helper(copt: char option) =
case copt of
NONE => (TextIO.closeIn ins; TextIO.closeOut outs)
| SOME(c) => (TextIO.output1(outs,c);helper(TextIO.input1 ins))
in
helper(TextIO.input1 ins)
end;
有人可以帮助我实现目标吗?