Continuation of this topic is here: 

I decided to create some new category – C++ Challenge. I would like to put here some problems which I would like to have solved the best way possible. If possible put solution in comments – remember to put your code in <pre></pre>.   Do not hesitate to use C++17 features (using CppCoreGuidelines is a plus 🙂 ).

Challenge: Decode raw bytes

Decode data from raw bytes to some data structure which is easy to use and is resource friendly.

You get n  bytes of data in which in each byte there is 0bFDDDFDDD  where F  is some flag and DDD  represents data. Lets assume you get pointer to data and number of bytes to read. Each FDDD  represents individual data pack.

Please propose data structures and some code which will do decoding. In the end I would like to be able to check F  flag and i.e. print value of DDD  without hassle.

I am looking forward to see your code!

About 

Service Delivery Manager and Scrum Master at Sii Poland company.

Since 2007 C++ enthusiast. C++11/14 evangelist - learn modern ways of developing in C++. Teaching TDD and agile way of coding.

  • googleplus
  • linkedin
  • twitter

Leave a Reply