c/c++的话,字符串赋值是要调用库函数拷贝的,不存在你说的问题。如果是从键盘输入,那就得选用接收空格的函数或用循环一个字符一个字符地输入。如gets和fgets是接收空格的,而scanf在接收字符串时是不接收空格的(遇到空格就截断了)。
if(pid_res > 0)
{
count = read(fd,output,BUFSIZ); // read the data from pipe
printf("father process read %d characters,they are: %s \n",count,output);
close(fd);
}