The IMO simplest way is using a union:
Just assign to one, read the other.
unsigned char a;
unsigned long l;
The other way is casting pointers:
The third way uses shifts (this is the one where you can control endianness):
unsigned long l = *reinterpret_cast<unsigned long *>(a);
In all cases, remember that on my Athlon64, gcc will have 8-byte longs, so the result might not be what you expect. If your compiler has it, include <stdint.h> and use uint32_t instead. This header is part of the C99 standard. If it doesn't have it, or you just want to be portable, include <boost/cstdint.hpp> from the Boost libraries. It defines the same types, but in the boost namespace.
unsigned long l = a | a << 8 | a << 16 | a << 24;