#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main(int argc, char **argv)
{
if(argc < 2){
fprintf(stderr, "faild Usage...\n");
exit(1);
}
int buffersize = atoi(argv[1]);
char buf[buffersize];
int n = 0;
while((n = read(STDIN_FILENO, buf, buffersize)) > 0){
if(write(STDOUT_FILENO, buf, n) != n){
perror("write()");
}
}
if(n < 0){
perror("read()");
}
exit(0);
}
标签:write,buffersize,buffer,char,int,IO,include,buf,size
From: https://blog.51cto.com/u_16470971/8969635