4918
5880
3万
GROAD
曲径通幽,安觅芳踪。
使用道具 举报
#include <errno.h> #include <unistd.h> ssize_t writen (int fd, const void *buf, size_t num) { ssize_t res; size_t n; const char *ptr; n = num; ptr = buf; while (n > 0) { if ((res = write(fd, ptr, n)) <= 0) { if (errno == EINTR) /*写入过程中发生了系统中断*/ res = 0; else return (-1); /*写入错误*/ } ptr += res; /*一次写入不到所希望的字节数,调整指针继续写*/ n -= res; /*n为剩下还没写的字节数*/ } return (num); }
本版积分规则 发表回复 回帖后跳转到最后一页
小黑屋|手机版|Archiver|曲径通幽 ( 琼ICP备11001422号-1|公安备案:46900502000207 )
GMT+8, 2025-11-2 06:35 , Processed in 0.072430 second(s), 21 queries .
Powered by Discuz! X3.2
© 2001-2013 Comsenz Inc.