This is the implementation of Shannon–Fano coding. You can find information about this algorithm here.
Also here you can find file for unit-testing in Visual Studio (CppUnitTestFramework).
make
./sh-fano input_file
./sh-fano
Then write this string. Output will be in type uint8_t that is casted to int for good looking.
-o output_file