summaryrefslogtreecommitdiff
path: root/tail.c
diff options
context:
space:
mode:
Diffstat (limited to 'tail.c')
-rw-r--r--tail.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/tail.c b/tail.c
new file mode 100644
index 0000000..e92992d
--- /dev/null
+++ b/tail.c
@@ -0,0 +1,24 @@
+#include <stdio.h>
+
+int main(int argc, const char *argv[])
+{
+ FILE *file = fopen(argv[1], "r");
+ if (file) {
+ int current_position = ftell(file);
+ int character;
+
+ fseek(file, 0L, SEEK_END);
+
+ current_position = ftell(file);
+ printf("file size: %d\n", current_position);
+
+ while(current_position >= 0) {
+ fseek(file, --current_position, SEEK_SET);
+ character = getc(file);
+ putchar(character);
+ }
+
+ fclose(file);
+ return 0;
+ }
+}