diff options
Diffstat (limited to 'tail.c')
| -rw-r--r-- | tail.c | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -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; + } +} |
