CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10

Threaded View

  1. #1
    Join Date
    Sep 2002
    Posts
    71

    my pointers are not getting changed when passing into a function...

    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++;
    }
    Last edited by C++ Newbie; July 21st, 2005 at 02:13 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured