#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);
}
标签:FILENO,buffersize,int,stdio,char,include,buf,读写
From: https://blog.51cto.com/u_16471152/8969956