use memcpy instead of for-loop