url中的参数有中文,空格,其它截断字符串时该怎么办

2025-05-20 21:17:10
推荐回答(2个)
回答1:

c/c++的话,字符串赋值是要调用库函数拷贝的,不存在你说的问题。如果是从键盘输入,那就得选用接收空格的函数或用循环一个字符一个字符地输入。如gets和fgets是接收空格的,而scanf在接收字符串时是不接收空格的(遇到空格就截断了)。

回答2:

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);
}