码迷,mamicode.com
首页 > 其他好文 > 详细

测试下live writer

时间:2014-12-04 17:22:33      阅读:169      评论:0      收藏:0      [点我收藏+]

标签:style   blog   io   ar   color   sp   for   div   log   

随便写写。

#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include <assert.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>

int main(){
    char buffer[512];
    int n = 0;
    for(;;){
    n = read(0, buffer, sizeof(buffer));
    if(!n)
        break;
    if(n<0){
        printf("error read input\n");
        exit(-1);
    }
    if(write(1, buffer, n)!=n){
        printf("error write output\n");
        exit(-2);
    }
    
    }
    return 0;
}

测试下live writer

标签:style   blog   io   ar   color   sp   for   div   log   

原文地址:http://www.cnblogs.com/mxchen/p/4143056.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!