Hi there

I have a problem with my code and am in a big rush to finish it and will be most grateful if someone could point me in the right direction.

The problem is suppose you want to compress an array of integers so that it uses less space which I'm showing in the code sample below.

I have several issues here. First, I don't know if I'm going in the right direction by converting int to char or short that use less space and result in the data being compressed. If I'm wrong here how else can I acheive compression? If I'm right, how can I store the resulting char and/or short and/or integer values togther in memory to use them later?

Second, How can I use bitwise operations instead of converting small int values to char/short to achieve compression?

I would really really appreciate if someone could show me some sample code instead of pointing me to numerous pages of algorithms on the web, as I'm very much short in time. I'll be most grateful.

Many thanks

The code:

Code:
void CompressData()
{
        int iIndex = 0;
        int iTempValue = 0;
        int iDeltaValue = 0;
        int iOriginalValue = 0;
        char charValue = 0;
        short shortValue = 0;
        const iBufferSize = 10;
 
        int dataBuffer[iBufferSize] = {67082, 67033, 67019, 67149, 67044, 67012, 66984, 66866, 66693, 65223};
 
        // Encode the data using delta encoding
        for (iIndex = 0; iIndex < iBufferSize; iIndex++)
        {
                iOriginalValue = dataBuffer[iIndex];
                                
                iDeltaValue = pDataBuffer[iIndex] - iTempValue;
 
                dataBuffer[iIndex] = iDeltaValue ;
 
                iTempValue = iOriginalValue;
 
                if (IsOneByteValue(iDeltaValue))
                {
                        charValue = (char) iDeltaValue;
                }
                else if (IsTwoByteValue(iDeltaValue))
                {
                        shortValue = (short) iDeltaValue;
                }
 
                // WHAT TO DO HERE? HOW CAN I SAVE ALL OF THE RESULTING CHAR OR SHORT OR INTEGER IN MEMORY SO THAT I CAN USE THEM LATER TO DECOMPRESS?
        }
 
}
 
bool IsOneByteValue(int iValue)
{
        if (iValue < 0)
        {
                if (iValue >= -128)
                        return true;
        }
        else
        {
                if (iValue <= 127)
                        return true;
        }
        
        return false;
}
 
 
bool IsTwoByteValue(int iValue)
{
        if (iValue < 0)
        {
                if (iValue >= -32768)
                        return true;
        }
        else
        {
                if (iValue <= 65535)
                        return true;
        }
        
        return false;
}