I have the following function that takes in 2 pointers, does copies and then returns. The problem I have is that when the function returns I want the pointers to have the modified values but they retain the original values. Can someone tell me why & how to fix it?
Code:unsigned char *p_source_buf;// {I set this to a memory buffer which read in a file}; unsigned char *pInBuf = new char[200]; unsigned int num_bytes_to_insert; void main(void){ byte_copy(m_pInBuf, p_source_buf, num_bytes_to_insert); } const unsigned int BITMASK_FOR_LEAST_SIGNIFICANT_TWO_BITS = 0x3; inline void byte_copy(unsigned char *p_in_buf, unsigned char *p_source_buf, unsigned int num_bytes_to_insert){ //Transfer remaining bytes individually unsigned int remaining_bytes = static_cast<unsigned int>(num_bytes_to_insert & BITMASK_FOR_SIGNIFICANT_TWO_BITS); for(unsigned int i=0;i<remaining_bytes;i++) *p_in_buf++ = *p_source_buf++; }




Reply With Quote