If you want to reconstitute a long type from char types, here is something that you can try beyond all the shifting / union.
unsigned char *uc_ptr; //unsigned char ptr, used for conversion
...
uc_ptr = (unsigned char *) &address; //point uc_ptr at the conversion results
*uc_ptr++=dat1; //assign the 1st char
*uc_ptr++=dat2; //assign the 2nd char
*uc_ptr++=dat3; //assign the 3rd char
*uc_ptr =dat4; //assign the 4th char
//after this point, address should contain the values represented by the four char types
Speed-wise, this will be as fast as the union approach and potentially faster. However, like the union approach, it is dependent on the compiler's endianess - so the code's portability is poor.