This post includes a HMC5883 Magnetometer Library for Arduino. It contains a library that makes interfacing with a compass module (for arduino) in C++ very easy. There are other libraries for the HMC5843, but...