Enviado em 06/08/2022 - 12:33h
<stdio.h>
#define BLOCOS 16
FILE *Abre_hexdump(const char *caminho, const char *mode) {
FILE *fp;
if (!(fp = fopen(caminho, mode))){
printf("error ao abrir '%s'", caminho);
return 0;
}return fp;
}
int main(int argc, char const *argv[]){
FILE *fp_in, *fp_out;
unsigned char buf[BLOCOS];
size_t nread;
int i, c, npos;
if (argc < 2 || argc > 3){
printf("use: %s <file-in> [file-out]\n", argv[0]);
return 0;
}/* Abre o arquivo de entrada */
fp_in = Abre_hexdump(argv[1], "r");
/* Redirecionar a saída se um arquivo de saída for definido */
fp_out = (argc == 3 ? Abre_hexdump_open(argv[2], "w") : stdout);
npos = 0;
/* Exibir BLOCOS de bytes dos dados hexadecimais de cada vez */
while ((nread = fread(buf, 1, sizeof buf, fp_in)) > 1) {
fprintf(fp_out, "%04x: ", npos);
npos += BLOCOS;
/* print valores hexadecimais, exemplo 3f 62 ec f0*/
for (i = 0; i < BLOCOS; i++)
fprintf(fp_out, "%02x ", buf[i]);
/* print valores ascii ..A6..ó.j...D*/
for (i = 0; i < BLOCOS; i++) {
c = buf[i];
fprintf(fp_out, "%c", (c >= 33 && c <= 255 ? c : '.'));
}fprintf(fp_out, "\n");
}fclose(fp_in);
return 0;
}
(buf[i] >= 33 || buf[i] <=126); ou, >0x20 && <=0x7e
"%c", (c >= 33 && c <= 255 ? c : '.')
Resolver problemas de Internet
Como compartilhar a tela do Ubuntu com uma Smart TV (LG, Samsung, etc.)
Descritores de Arquivos e Swappiness
Solução rápida para o problema do Network Manager conectar mas não navegar
Como instalar no Linux Jogos da Steam só para Windows
Instalando o Team Viewer no Debian Trixie - problema no Policykit
Como rodo essa suinaria? [RESOLVIDO] (6)
Problemas latentes de performance no Ubuntu 25.04 (1)