Accessing a certain Memory Location

This is a discussion on Accessing a certain Memory Location within the C Programming forums, part of the General Programming Boards category; I have a memory address. I want to output the content of this memory address.how can I do this in ...

It's pretty straightforward. You cast the address--as a literal value--to a pointer of suitable type for how you're going to use it. The pointer then points to that address and you can use it just like a pointer to any other memory. The only difference is that you should make the pointer volatile because it refers to memory outside of your control.

It's pretty straightforward. You cast the address--as a literal value--to a pointer of suitable type for how you're going to use it. The pointer then points to that address and you can use it just like a pointer to any other memory. The only difference is that you should make the pointer volatile because it refers to memory outside of your control.

Ps I am not sure how the (char *) works
is that simply saying convert the value to a char type pointer?

I can get lots of crap to compile too, but it doesn't mean it will run. your code is not dereferencing the addr variable. Yes, it will compile, but you can't do anything with it. Try this, which crashes too.

> I have a memory address.
How about starting at the beginning, by stating what it is you actually hope to achieve with this.
Because very few machines will tolerate you picking out random memory locations and then going and looking to see what's there.

Don't forget to mention what your real operating system and compiler is.

I can get lots of crap to compile too, but it doesn't mean it will run. your code is not dereferencing the addr variable. Yes, it will compile, but you can't do anything with it. Try this, which crashes too.