C 標準管道send

2021-06-02 13:09:09 字數 762 閱讀 9133

#include #include #include #include #include #define pipe_name "/tmp/dpfifo"   

#define buffer_size pipe_buf

//pipe_buf為limits.h定義的管道最大容量

int main(void)

}

strcpy(buffer,"this is write the pipe\n");

len=strlen(buffer);

alllen= len*2;

//開啟管道,管道都是fifo

printf("process %d opening pipe !",getpid());

pipe_fd=open(pipe_name,o_wronly);

printf("process %d result %d\n",getpid(),pipe_fd);

if (pipe_fd!=-1)

bytes_sent+=res;//res為本次寫的位元組數,bytes_sent為總位元組數

}

close(pipe_fd);

}

else

printf("%d bytes sended!\n",bytes_sent);

return 0;

}

標準I O和管道

標準輸入 0 標準輸出 1 錯誤輸出 2標準輸入 stdin 0 預設接受來自鍵盤的輸入 標準輸出 stdout 1 預設輸出到終端視窗 標準錯誤 stderr 2 預設輸出到終端視窗改變檔案儲存的預設位置 格式 命令 操作符號 檔名 支援的操作符號包括 把標準輸出重定向到檔案 把輸出內容重定向追加...

標準I O和管道

重定向 redirect 標準輸入和輸出程式 指令 資料 讀入資料 input 輸出資料 output 開啟的檔案都有乙個fd file descriptor 檔案描述符 dev std proc self fd 終端linux給程式提供三種i o管道標準輸入 stdin 0 預設接受來自鍵盤的輸入...

標準IO和管道

1 將 etc issue檔案中的內容轉換為大寫後儲存至 tmp issue.out檔案中 1.cat etc issue tr a z a z tmp issue.out 2.tr a z a z tmp issue.out 2 將當前系統登入使用者的資訊轉換為大寫後儲存至 tmp who.out...