CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2005
    Location
    Bangalore, India
    Posts
    52

    Memcpy with unsigned long src address

    I have declared an unsilgned long;

    char *reg = new char(reg_size);
    unsigned long reg_address = 1bece08;
    reg_address = reg_address | 0xe0000000;
    memcpy(reg, (const void *) reg_address, reg_size);

    memcpy is not working, as I am always getting junk values in them. I also tried memset, but no use?

    Please let me know if anything is visibly wrong?
    Cheers,
    MKS
    Impossible is always the one untried...

  2. #2
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Memcpy with unsigned long src address

    Quote Originally Posted by srikanth_mk
    I have declared an unsilgned long;

    char *reg = new char(reg_size);
    What does the last line do? It allocates a single character, and assigns the value of reg_size to it.

    This is what you want to do:
    Code:
    char *reg = new char [reg_size];
    Regards,

    Paul McKenzie

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