Re: How to read/write an 'address' from a memory location......
- From: Hans-Bernhard Bröker <HBBroeker@xxxxxxxxxxx>
- Date: Fri, 19 Oct 2007 21:04:22 +0200
aeroboro221@xxxxxxxxxxxxxx wrote:
I am trying to read an address from a memory location and then write
into that memory location.
Which "that" --- the one you read the address from, or the one the address specifies?
unsigned long * mem_pointer = 0x93700020;
unsigned long mem_value = *mem_pointer;
The question is - How do i use the value at <i> mem_value </i> as an
address?
An address kept in a variable is called a pointer, in C programs. So mem_value should be of a pointer type, rather than an integer. Consequentially, mem_pointer should be a pointer-to-pointer-to-something type, e.g.
some_type **mem_pointer = ...;
some_type *mem_value = *mem_pointer;
some_type the_actual_thing = *mem_value;
Basically, I want to do something like.
*(unsigned char *)mem_value = 10.
And what's keeping you from doing exactly that?
But this all hides a probably more important question: why do you think you should be doing this?
.
- Follow-Ups:
- Re: How to read/write an 'address' from a memory location......
- From: aeroboro221
- Re: How to read/write an 'address' from a memory location......
- References:
- How to read/write an 'address' from a memory location......
- From: aeroboro221
- How to read/write an 'address' from a memory location......
- Prev by Date: Re: MSP430 mcu: Display characters on terminal I/O __ IAR simulator
- Next by Date: Re: "default" or "startup" .config file for arm linux 2.6.22.10
- Previous by thread: Re: How to read/write an 'address' from a memory location......
- Next by thread: Re: How to read/write an 'address' from a memory location......
- Index(es):
Relevant Pages
|