I'm seeing a weird problem with memcpy. I have the following code:
Ok, I expected a = 1, but for some bizarre reason, c = 5! It skipped over 4 completely. Not only that, but b = 3 and 4, it skipped over 2! This totally messes up all of my code.Code:int main() { char data[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 }; struct mystruct { char a; short b; char c; long d; char e; short f; char g; } ms; memcpy(&ms, data, 16);
Whats the best way to fix this issue without manually specifying offsets (i.e. c = data[3]) and make sure all the other values equal what they are supposed to?



LinkBack URL
About LinkBacks



