完成了第 13 章 多种 I/O 函数

This commit is contained in:
riba2534
2019-01-26 23:06:34 +08:00
parent 2e153efab4
commit 11ad16ac8a
4 changed files with 565 additions and 1 deletions

20
ch13/writev.c Normal file
View File

@@ -0,0 +1,20 @@
#include <stdio.h>
#include <sys/uio.h>
int main(int argc, char *argv[])
{
struct iovec vec[2];
char buf1[] = "ABCDEFG";
char buf2[] = "1234567";
int str_len;
vec[0].iov_base = buf1;
vec[0].iov_len = 3;
vec[1].iov_base = buf2;
vec[1].iov_len = 4;
str_len = writev(1, vec, 2);
puts("");
printf("Write bytes: %d \n", str_len);
return 0;
}