What I was thinking of was
Code:
memcpy(&bob, data, sizeof(data));
which would put them all in, in one shot. But you would need to make sure that the offsets are right, otherwise things won't be aligned correctly. (And actually, you could also use sizeof to check -- if sizeof(bob) == 8, then we've not got any padding. That's easier than checking all the offsets. I don't know why I didn't think of it.)
However, if there's padding you could do separate memcpy's to make sure you honor the padding your compiler has chosen for you:
Code:
memcpy(&bob + offsetof(dataStruct, var1), &data[0], sizeof(bob.var1));
memcpy(&bob + offsetof(dataStruct, var2), &data[1], sizeof(bob.var2));
memcpy(&bob + offsetof(dataStruct, var3), &data[3], sizeof(bob.var3));
memcpy(&bob + offsetof(dataStruct, var4), &data[4], sizeof(bob.var4));
This has the advantage of working despite whatever the layout of dataStruct is.