well, the snarky answer is: don't have random generate unsigned longs, have it generate unsigned chars.
The other answer is to just cast it.
unsigned char * cp;
uint64_t big = 12345689101112ull;
cp = (unsigned char*) &big;
//you can address cp[0] ... cp[7] as 64 bit int has 8 bytes, 0-7 are now accessible here, eg
cout << cp[5];
its more efficient, though, to copy integers into integers.
...
unsigned long * ul = (unsigned long*) &pData;
for(int i = 0; i < something; i++)
{
ul[i] = randomval;
}
basically, you can cast ANY type of pointer to any other pointer type. It is mostly useful in casting anything to bytes (for file writes or networking etc) and back again, but you can slice it however. So your options are to work with it byte wise (slower) and copy each block of bytes from random into the data one by one, or to copy them in blocks one int at a time (sizeof type times faster!). The 8 bytes at a time copy is a big speedup for large byte buffers, if you get into images or other such things that are huge and need to be copied quickly.