
// example of the write() system call:  writes the bytes 0x89 and 0xc1
// to a newly-created file, "abc"

/* confirmation via UNIX od command:

myprompt% od -t x1 abc
0000000 89 c1
0000002

*/

// note:  fprintf() is not safe for use with non-ASCII data

#include <fcntl.h>  // O_WRONLY etc. defined here

char c[2];

int f;

main()

{ f = open("abc",O_WRONLY|O_CREAT,0700);  // open new file for writing
  c[0] = 0x89;
  c[1] = 0xc1;
  write(f,c,2);
  close(f);
}


