#include <oxstd.h>
main()
{
    decl file, x, i;

    file = fopen("iotest9.fmt", "wbf");  // write

    fwrite(file, ones(1, 4));
    fwrite(file, 1 + ones(1, 4));
    fwrite(file, zeros(27, 4));

    fclose(file);

    file = fopen("iotest9.fmt", "abf");  // append
    println("file is ", rows(file), " by ", columns(file));

    fwrite(file, 2 + ones(1, 4));
    fclose(file);

    file = fopen("iotest9.fmt", "rbf");    // read
    println("file is ", rows(file), " by ", columns(file));

    fseek(file, 'f', 1);             // second row
    fread(file, &x, 'f', 1);            // read it
    print("row of twos:", x);

    fseek(file, 'f', rows(file)-1);  // second row
    fread(file, &x, 'f', 1);   // read it
    print("row of threes:", x);
}
