📄 readline.c
字号:
#include <stdio.h> /* standard C i/o facilities */#include <unistd.h>/* readline - from the Stevens book (Unix Network Programming) */intreadline(int fd, void *vptr, int maxlen){ int n, rc; char c, *ptr; ptr = vptr; for (n = 1; n < maxlen; n++) { if ( (rc = read(fd, &c, 1)) == 1) { *ptr++ = c; if (c == '\n') break; } else if (rc == 0) { if (n == 1) return(0); /* EOF, no data read */ else break; /* EOF, some data was read */ } else return(-1); /* error */ } *ptr = 0; return(n);}/* end readline */int writeline( int fd, char *s ) { int res; res = write(fd,s,strlen(s)); if (res!=strlen(s)) return(-1); if (2!=write(fd,"\r\n",2)) return(-1); return(res+2);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -