8 static char buffer[BUFSIZE];
12 int __fd = open(f, o); \
14 printf("open failed: %s (error: %d)", f, errno); \
21 main(int argc, const char* argv[])
23 int fd = 0, fdrand = 0;
24 int size = 0, sz2 = 0;
26 fd = _open(argv[1], O_RDWR | O_CREAT);
27 fdrand = _open("/dev/rand", O_RDONLY);
29 for (int i = 0; i < 100; i++)
31 printf("write to file: (round) {%d}/100\n", i + 1);
33 size = read(fdrand, buffer, BUFSIZE);
34 printf(">>> read random chars: %d\n", size);
35 for (int i = 0; i < size; i++)
37 buffer[i] = (char)((unsigned char)(buffer[i] % 94U) + 33U);
40 sz2 += write(fd, buffer, size);
41 sz2 += write(fd, "\n\n", 2);