Created
June 25, 2020 19:45
-
-
Save JonathonAnderson/35cbfa1195e5db65e7195017665a75d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main(int argc, char* argv[]) | |
{ | |
FILE *fpt; | |
char byte; | |
long int where,move; | |
if(argc != 2) | |
{ | |
printf("Usage: fileseek filename\n"); | |
return(0); | |
} | |
fpt = fopen(argv[1], "r"); | |
if(fpt == NULL) | |
{ | |
printf("Unable to open file %s for reading\n", argv[1]); | |
return(0); | |
} | |
while(1) | |
{ | |
where = ftell(fpt); | |
fread(&byte,1,1,fpt); | |
fseek(fpt,-1,SEEK_CUR); | |
printf("Byte %d: %d (%c)\n", where, byte, byte); | |
printf("Enter #bytes (+ or -) to move, or 0 to quit: "); | |
scanf("%d", &move); | |
printf("move: %d\n", move); | |
if(move == 0) | |
break; | |
fseek(fpt,move,SEEK_CUR); | |
} | |
fclose(fpt); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment