1#include <unistd.h>
2#include <fcntl.h>
3
4int main()
5{
6 int filedesc = open("testfile.txt", O_WRONLY | O_APPEND);
7 if(filedesc < 0)
8 return 1;
9
10 if(write(filedesc,"This will be output to testfile.txt\n", 36) != 36)
11 {
12 write(2,"There was an error writing to testfile.txt\n"); // strictly not an error, it is allowable for fewer characters than requested to be written.
13 return 1;
14 }
15
16 return 0;
17}
18