Advertisement
Guest User

Untitled

a guest
Jan 25th, 2020
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.40 KB | None | 0 0
  1. int main(char argv**) {
  2.  
  3.    FILE *fp;
  4.    char ch;
  5.    int num;
  6.    long length;
  7.  
  8.    fp = fopen(argv[1], "r");
  9.    if (fp == NULL) {
  10.       puts("cannot open this file");
  11.       exit(1);
  12.    }
  13.  
  14.    fseek(fp, 0, SEEK_END);
  15.    length = ftell(fp);
  16.    fseek(fp, (length - 1), SEEK_SET);
  17.  
  18.    do {
  19.       ch = fgetc(fp);
  20.       putchar(ch);
  21.    } while (ch != EOF);
  22.  
  23.    fclose(fp);
  24.    return(0);
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement