So I wrote this function a while ago, and I thought it was kind of neat.
You can replace bool variable; with a declaration of any type, and the output will be the binary representation of the variable or object, translated to English endian-ness (at least on Windows XP using GCC (Dev-C++), not sure if it depends on OS or compiler or both).
P.S. Let me know if you think there's a better way to do this.