#include <oxstd.h>
main()
{
    decl file, x = rann(2,3);
    x[0][] = double("tinker");
    savemat("iotest6a.fmt", x);
                                 // force little-endian mode
    file = fopen("iotest6b.fmt", "wbe");
//  two ways if writing signature, first:
//  decl s = new string[4];      // need four bytes
//  s[0:2] = "\xDD\xEE\x86";     // signature is DDEE8600
//  fwrite(file, s);
//
//  and second way:
    fprint(file, "%c", 0xdd, "%c", 0xee, "%c", 0x86, "%c", 0x00);

    fwrite(file, rows(x));
    fwrite(file, columns(x));
    fwrite(file, rows(x) * columns(x) * 8);
    fwrite(file, x);
    fclose(file);

    decl y = loadmat("iotest6b.fmt");

    println(string(x[0][0]), string(y[0][0]), x[1][1]-y[1][1]);
}
