The sequence of steps is pretty well set out in the manual. Start at http://www.bzip.org/1.0.5/bzip2-manual-1.0.5.html#bzcompress-init
and work your way down the page! As you haven't got any code in there to do with compression just give it a stab. Sling in the three calls you need to use the low level interface and go from there. If you check the return codes it gives you some pretty hefty hints about what's going wrong.
Read the bits about what to do with the bz_stream structure VERY carefully. Remember it's not a C++ object so you can't rely on a constructor, you have to zero out all the fields by hand or use something like std::memset. My guidelines would be:
- allocate a bz_stream object
- clear it with std::memset
- allocate an output buffer, you've already got an input buffer. Make it the same size as the input buffer at first, compressed data probably isn't going to be bigger than the input data
- call BZ2_bzCompressInit on the structure
- set all the pointers and sizes you need to in the bz_stream structure
- call BZ2_bzCompress. As you've already read your complete file you can do it in one call
- write the compressed data to a file
- clean up by calling BZ2_bzCompressEnd and, if necessary freeing the bz_stream object
Anyway, bash out some code, give it a run and if it fails in a way you don't understand what's going wrong we'll try and help. BUT try and write the code first.
Edited as I didn't check my spellung.