using memcpy to copy array