Click to See Complete Forum and Search --> : Memcpy with unsigned long src address


srikanth_mk
August 30th, 2007, 04:37 AM
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?

Paul McKenzie
August 30th, 2007, 08:14 AM
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:

char *reg = new char [reg_size];

Regards,

Paul McKenzie