Hello,

I have a basic c++ STL question. I have an octet array class (legacy).

Now lets say the octet array has the following contents:
array[0]=00
array[1]=01
array[2]=30
array[3]=01
array[4]=114

The key we need to generate from the above array should match ["00130-1-114"]

Whats the best way to get this from the above array.

In the legacy code, there is way to convert, but is using lot of magic numbers everywhere, it is quite not readable..

~pdk

You key is ambiguous considering your array. If you concatenate the first two elements (as text) you get "0001", your key leads with "001". Did you use "0" + "01" or "00" + "1"?
In addition, are you guaranteed that the last value is 3 digits? What about the others - what if they end up being 3 digits? How does that affect the format of the key.

It might be helpful if you give the requirements of the key (i.e. what is valid/invalid, what it should match, ...). At least then we can suggest a proper approach.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.