summaryrefslogtreecommitdiff
path: root/tailf.c
diff options
context:
space:
mode:
Diffstat (limited to 'tailf.c')
-rw-r--r--tailf.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/tailf.c b/tailf.c
new file mode 100644
index 0000000..389e6a0
--- /dev/null
+++ b/tailf.c
@@ -0,0 +1,27 @@
+#include <stdio.h>
+
+int main(int argc,char *argv[]) {
+ short in;
+ FILE *fp;
+ if(argc>1) {
+ if(!(fp=fopen(argv[1],"r"))) {
+ printf("file not found.\n");
+ return 1;
+ }
+ while(1) {
+ if((in=fgetc(fp)) == -1) {
+ if(feof(fp)) {
+ clearerr(fp);
+ } else {
+ printf("unknown error from fgetc()");
+ return 2;
+ }
+ } else {
+ printf("%c",in);
+ fflush(stdout);
+ }
+ }
+ } else {
+ printf("usage: tailf filename\n");
+ }
+}