This commit is contained in:
2025-07-03 13:14:37 +03:00
parent 1b84da8f9d
commit afc368f33e

View File

@@ -1,36 +0,0 @@
use std::env;
use std::fs::File;
use std::io::{self, Read};
fn main() -> io::Result<()> {
// Get the file name from command line arguments
let args: Vec<String> = env::args().collect();
if args.len() < 2 {
eprintln!("Usage: {} <filename>", args[0]);
return Ok(());
}
let filename = &args[1];
// Open the file
let mut file = File::open(filename)?;
let mut buffer = Vec::new();
// Read the file into the buffer
file.read_to_end(&mut buffer)?;
// Print the hex dump
for (i, byte) in buffer.iter().enumerate() {
// Print the address
if i % 16 == 0 {
if i != 0 {
println!(); // New line after every 16 bytes
}
print!("{:08x} ", i);
}
// Print the byte in hex format
print!("{:02x} ", byte);
}
println!(); // Final new line
Ok(())
}