Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #define SIZE 2000
  5.  
  6. int main()
  7. {
  8. FILE *filePtr;
  9. char arr[SIZE];
  10. printf("Please enter the file you would like to open: \n");
  11. scanf("%s", arr);
  12. strcat(arr,".txt");
  13.  
  14. filePtr = fopen(arr, "r");
  15. if(filePtr == NULL)
  16. {
  17. fprintf(stderr, "There was a problem opening the file \n");
  18. perror("Leaving now!!!\n");
  19. exit(-1);
  20. }
  21.  
  22. char aByte;
  23. int i;
  24.  
  25. printf("Offset:\t\tHexadecimal data format:\t\t\tCharacter Format:\n");
  26.  
  27. while(fread(arr, 1, 16, filePtr) > 0)
  28. {
  29.  
  30. //NEED OFFSET AROUND HERE
  31.  
  32. for(i = 0; i < 16; i++)
  33. {
  34. if(isprint(arr[i]))
  35. printf("%x ", arr[i]);
  36. else
  37. printf("." );
  38. }
  39. printf("\t");
  40. for(i = 0; i < 16; i++)
  41. {
  42. printf("%c ", arr[i]);
  43. }
  44.  
  45. printf("\n");
  46. }
  47. fclose(filePtr);
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement