I swear I used to know how to do this ... so I have this array:

BYTE bcdData[6];

and a function that returns it:

BYTE * BCD::GetBcdData()
	return bcdData;

and I have this other array in another class:

BYTE tpIdByte[2];

And what I am trying to is take the values from bcdData array and place them in tpIDByte array. And I am running into a total blank on how to do it...

Thanks for the help.

7 Years
Discussion Span
Last Post by ChaseRLewis

You are trying to fit 6 bytes into 2, in general it's not possible, unless the data in bcd are very trivial or you can compress it. What kind of data does bcd hold? It might be possible if the data in bcd are small enough that you can use some compression techniques.


few ways

you can do something like

BCD foo;
tpldByte[0] = foo.getBcdData()[1];

where the arrays start at zero so 1 is the second value in the bcdData array and 0 is the first value in the tpldByte.
So if I wanted the last in tpldByte to equal the last byte of bcdData

tpldByte[1] = foo.getBcdData()[5];

you can also use memcpy for larger assignemtnts.

Edited by ChaseRLewis: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.