
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 : '.')
Cirurgia para acelerar o openSUSE em HD externo via USB
Void Server como Domain Control
Modo Simples de Baixar e Usar o bash-completion
Monitorando o Preço do Bitcoin ou sua Cripto Favorita em Tempo Real com um Widget Flutuante
Atualizar Linux Mint 22.2 para 22.3 beta
Jogar games da Battle.net no Linux com Faugus Launcher
Como fazer a Instalação de aplicativos para acesso remoto ao Linux
Conky, alerta de temperatura alta (11)
Assisti Avatar 3: Fogo e Cinzas (3)
Duas Pasta Pessoal Aparecendo no Ubuntu 24.04.3 LTS (42)









