PreviousUpNext

5.5.46  Write a text file

Write a text file:

    fd = file::open_for_write "foo.txt";
    file::write (fd, "There is no royal road to mathematics.\n");
    fprintf      fd  "Mathematics is the %s of the sciences.\n" "queen";
    file::flush  fd;
    file::close_output  fd;

Here is another way of doing the same thing:

    file::from_lines
        "foo.txt"
        [ "There is no royal road to mathematics.\n",
          sprintf "Mathematics is the %s of the sciences.\n" "queen"
        ];

Comments and suggestions to: bugs@mythryl.org

PreviousUpNext