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.

Recommended Answers

All 2 Replies

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.

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.