#include #include // TEXT FILES with numbers in them int main(int argc, char *argv[]){ if(argc < 2){ fprintf(stderr,"usage....\n"); exit(1); } FILE *f = fopen(argv[1],"r"); if(f == NULL){ perror(""); exit(1); } //int byte; //while( (byte = fgetc(f)) != EOF){ // printf("0x%02x\n", byte); //} //print out last byte in the file? fseek(f,-1, SEEK_END); int byte; if( (byte = fgetc(f)) != EOF){ printf("0x%02x\n", byte); } else { printf("This is the end of file\n"); } fseek(f,3, SEEK_SET); if( (byte = fgetc(f)) != EOF){ printf("0x%02x\n", byte); } else { printf("This is the end of file\n"); } long current_pos = ftell(f); printf("%lu\n",current_pos); fclose(f); return 0; }