c - Copying a pointer for bit operations -
i have function passes in struct , instead of doing bit manipulations on arr want create copy. how can make copy of element of array of unsigned ints bit manipulations on?
unsigned int * arr = cs->arr; // cs->arr set unsigned int * arr; unsigned int copy; memcpy(copy,arr[0], sizeof(unsigned int)); // copy copy first element, int = 0; while(copy != 0) { += copy & 1; copy >>= 1; } return i;
thank you!
you dont need memcopy
. simple array access enough:
unsigned int copy = cs->arr[0]; int = 0; while(copy != 0) { += copy & 1; copy >>= 1; } return i;
Comments
Post a Comment