Well, it's fairly trivial to make a program given the ideas that were discussed in this thread. Here's one that prints the last few characters of a line providing the stream is seekable:
Code:#include <stdio.h> #include <stdlib.h> enum { LIMIT = 4 }; int main(void) { char buf[LIMIT + 1]; int c, count = 0; while ((c = getchar()) != EOF) { int flush = c == '\n'; count += !flush; if (!flush) continue; flush = count >= LIMIT; count = 0; if (!flush) continue; if (fseek(stdin, -LIMIT - 1, SEEK_CUR) || !gets(buf)) return EXIT_FAILURE; puts(buf); } }Yes, and it doesn't need to be an assumption.So the assumption is the problem.



40Likes
LinkBack URL
About LinkBacks



