-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwriter.c
36 lines (35 loc) · 1.12 KB
/
writer.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include<stdio.h>
#include<fcntl.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/stat.h>
int main(void) {
int fd, i;
int bytes_written;
char buf[51200];
for (i = 0; i < sizeof(buf); i++) {
buf[i] = 'a';
}
fd = open("./delme.txt", O_WRONLY | O_CREAT, 0777);
bytes_written = write(fd, buf, sizeof(buf));
printf("%d bytes written\n", bytes_written);
printf("_______\n");
bytes_written = write(fd, buf, sizeof(buf));
printf("%d bytes written\n", bytes_written);
bytes_written = write(fd, buf, sizeof(buf));
printf("%d bytes written\n", bytes_written);
printf("_______\n");
bytes_written = write(fd, buf, sizeof(buf));
printf("%d bytes written\n", bytes_written);
bytes_written = write(fd, buf, sizeof(buf));
printf("%d bytes written\n", bytes_written);
printf("_______\n");
bytes_written = write(fd, buf, sizeof(buf));
printf("%d bytes written\n", bytes_written);
bytes_written = write(fd, buf, sizeof(buf));
printf("%d bytes written\n", bytes_written);
printf("_______\n");
bytes_written = write(fd, buf, sizeof(buf));
printf("%d bytes written\n", bytes_written);
close(fd);
}