954,499 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

pointers

i want to know, what kind of addresses do pointers deal with? i mn logical or physical? and how can i access a particular memory area using pointers?
PLEASE HELP.......

arshi9464
Light Poster
44 posts since Aug 2009
Reputation Points: 8
Solved Threads: 0
 

I am not a 100% sure on this but I believe pointers work with logical memory.
When a C program is compiled, the compiler works in such a manner that the program can be placed any where in the physical memory.

I dont think that you can access a physical memory location from within the program

abhimanipal
Master Poster
742 posts since Dec 2009
Reputation Points: 114
Solved Threads: 104
 

Then how can pointers be dangerous if they access logical addresses, CPU generated addresses keep on changing after every access?

arshi9464
Light Poster
44 posts since Aug 2009
Reputation Points: 8
Solved Threads: 0
 
i want to know, what kind of addresses do pointers deal with?


That's not specified.and how can i access a particular memory area using pointers?
It's not portable, but traditionally that's been done by something like this:

/* Point to address 0x12345678 and treat it as an int */
int *p = (int*)0x12345678;
Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 
how can i access a particular memory area using pointers?


Why do you want to do this? What kind of memory area is this? Maybe there are OS API functions that do exactly what you want.
For example, if you want to write a cheat engine on windows, you can use these two to mess with memory of other processes: http://msdn.microsoft.com/en-us/library/ms680553(v=vs.85).aspx (ReadProcessMemory)
http://msdn.microsoft.com/en-us/library/ms681674(v=vs.85).aspx (WriteProcessMemory)

m4ster_r0shi
Posting Whiz in Training
230 posts since Mar 2010
Reputation Points: 154
Solved Threads: 31
 

It's a function of your OS and compiler.

If you're using a protected OS and your compiler is compatible with your OS (say Linux+gcc or Windows+visual studio), then you're dealing with logical addresses. You can invent whatever address you like, but if you choose badly, the OS will just serve up your ass on a plate with a segmentation fault.

If you're using a protected OS and your compiler is NOT compatible with your OS (say Windows+TurboCrap), then you're dealing with physical addresses in a virtual machine. You can invent whatever address you like, but the VM will either allow it or give you some fake answer (which is mostly in keeping with what the real machine would do).

If you're using a real mode OS (eg. DOS), or no OS at all, then you're using real addresses, and you can do whatever the hell you like. This includes destroying your hardware if you choose badly. There is no safety net, you're on your own.

Salem
Posting Sage
Team Colleague
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
 

no no frnds whan we declaire any variable or pointer variable than its cover any very memory space its allocated any where in primary memory and its does not change after compiletion.

wtstalin88
Newbie Poster
16 posts since Jun 2011
Reputation Points: -5
Solved Threads: 2
 

Your question seems upside down:

"How I can use this solution, which does not work or does not work allways, to problem I have which I do not tell to you"

pyTony
pyMod
Moderator
5,359 posts since Apr 2010
Reputation Points: 782
Solved Threads: 852
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: