This project is a console-based hex viewer written in C++. It compiles into a native Windows executable and can read any file as raw hexadecimal bytes.
- Visual Studio Build Tools (MSVC)
- Use x64 Native Tools Command Prompt for VS
- No Qt, no GUI libraries, no CMake required
Always compile using:
Visual Studio 2026 x64 Native Tools Command Prompt
PowerShell alone will NOT work for compiling.
You must be inside the folder that contains main.cpp.
cd C:\Users\David\cpp-hex-viewerVerify files exist:
dirYou should see:
main.cpp
Run this command from inside the project folder:
cl /std:c++20 /EHsc main.cppThis creates:
main.exe→ the hex viewer program
You only need to compile again if you change the code.
General syntax:
main.exe <file_path>The program prints the file contents as hexadecimal bytes.
Read a binary file:
main.exe test.binRead a text file:
main.exe notes.txtRead an image:
main.exe image.pngRead a file in another folder (full path):
main.exe C:\Users\David\Downloads\file.binRead a file using a relative path:
main.exe ..\Downloads\file.bin-
The program reads any file (text or binary)
-
The program does NOT modify files (read-only)
-
Compilation requires MSVC
-
Running
main.exeworks in any terminal -
❌ Running cl from PowerShell
✅ Compile once, reuse forever
✅ Pass any file path you want
cl main.cpp→ builds the toolmain.exe file→ uses the tool on any file