我想把 x=1.11, y=2.22, 通过FIFO传输。
写端:
sprintf(buf,"%f",x);
write(writefd,buf,sizeof(buf));
sprintf(buf,"%f",y);
write(writefd,buf,sizeof(buf));
读端:
read(readfd,buf,sizeof(buf));
float x=atof(buf);
printf("x=%f\n",x);
read(readfd,buf,sizeof(buf));
float y=atof(buf);
printf("y=%f\n",y);
结果 x=1.110000 y=1.110000
出了哪些错误?怎么写比较好?