Tag: bc

通过C中的管道向bc写一个术语

我遇到了这个C练习的问题。 任务是创建两个进程。 这两个管道连接两个管道,终止于孩子的stdin和stdout。 然后用bc替换子进程。 然后我应该从父进程到子进程(bc)写一个术语(例如1 + 2)。 管道正在做他们应该做的事情,但是,bc似乎不喜欢输入。 当我写入管道时,bc会响应以下多行: (standard_in) 1: illegal character: ^@ 到目前为止这是我的解决方案: #include #include #include #include int main(int argc, char *argv[]) { /*Create two pipes: One from parent to child (pipe_pc) and one from child to parent (pipe_cp). */ int pipe_pc[2], pipe_cp[2]; int cid; if (pipe(pipe_pc) == -1 || pipe(pipe_cp) == -1) […]