Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #define SIZE 2000
- int main()
- {
- FILE *filePtr;
- char arr[SIZE];
- printf("Please enter the file you would like to open: \n");
- scanf("%s", arr);
- strcat(arr,".txt");
- filePtr = fopen(arr, "r");
- if(filePtr == NULL)
- {
- fprintf(stderr, "There was a problem opening the file \n");
- perror("Leaving now!!!\n");
- exit(-1);
- }
- char aByte;
- int i;
- printf("Offset:\t\tHexadecimal data format:\t\t\tCharacter Format:\n");
- while(fread(arr, 1, 16, filePtr) > 0)
- {
- //NEED OFFSET AROUND HERE
- for(i = 0; i < 16; i++)
- {
- if(isprint(arr[i]))
- printf("%x ", arr[i]);
- else
- printf("." );
- }
- printf("\t");
- for(i = 0; i < 16; i++)
- {
- printf("%c ", arr[i]);
- }
- printf("\n");
- }
- fclose(filePtr);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement