#include #include #include int putchar(int c); int getchar(void); int getc(FILE* stream); int fflush(FILE *stream); void waitkey(void); void exit(int status); ssize_t read(int fd, void *buf, size_t count); int WAIT = 1; int main(){ int c; int nl = 0; int b = 0; while((c=getchar()) != EOF){ putchar(c); b++; if (c == '\n') nl++; if (nl >= 16 || (c == '\n' && b >= 512)){ fflush(stdout); if(WAIT){ waitkey(); } nl = 0; b = 0; } } } void waitkey(void){ unsigned char s[2]; if(read(fileno(stderr), &s, 2) > 0){ if (s[0] == 'q') exit(0); if (s[0] == 'r') WAIT=0; } }