더보기
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | #include <stdio.h> #include <stdlib.h> #include <ctype.h> void print(FILE *fp); int main(int argc, char *argv[]) { if (argc != 2) { printf("usage : %s filename\n", argv[0]); return 0; } FILE *fp; fp = fopen(argv[1], "rb"); if (fp == NULL) { printf("[%s] is not exist or file open error.\n", argv[1]); return 0; } print(fp); fclose(fp); return 0; } void print(FILE *fp) { char * ascii; ascii = (char*)malloc(sizeof(char) * 17); int index = 0x0; int d; while (1) { printf("0x%X :", index); if (index < 0x1000) printf("\t\t\t"); else if (index < 0x10000) printf("\t\t"); for (int i = 0; i <= 15; i++) { d = fgetc(fp); if (d >= 0x20 && d < 0x7f) ascii[i] = d; else ascii[i] = '.'; if (feof(fp)) { printf("\n"); free(ascii); return; } printf("%.2X ", d); } ascii[16] = 0; printf("\t%s\n", ascii); index += 0x10; } } | cs |

연습 겸 만들어봤던 것이다.
깃허브 레포지토리 낭비같아 코드 작성한 것 복붙 후 삭제했다.
'개발, 연습' 카테고리의 다른 글
[파이썬] 파이썬 string 여러 형태 지정 (0) | 2021.04.28 |
---|---|
[웹 크롤러] 파이썬 웹 크롤러 with Selenium (0) | 2021.04.03 |
[재미] 아두이노 레오나르도 스타크래프트 매크로 (0) | 2021.03.17 |
vscode extension installation from VSIX (0) | 2020.12.20 |
[C++] 예외 처리 (0) | 2020.07.11 |