0

Hi,

I found a number of post talking about this in C, but could not solve it in C++.

I have 4 hex characters to represent a length. These need to be stored like this, in the case where length=16 (this online converter told me that 16 converts to A in hex).

`char bufferlength[4] = {0x00,0x00,0x00,0x0A};`

My problem. How do I get this, when all I have is length=300.

I have heard people mentioning DWORD, and also found the following code that converts an int n to hex. But I would like to find a built in function that handles the conversion for me.

```
for (int i=2*sizeof(int) - 1; i>=0; i--) {
cout << "0123456789ABCDEF"[((n >> i*4) & 0xF)];
}
```

Any ideas on how to convert 1 int into hex and store in the the char[4] array?

Many many thanks!