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.......

Recommended Answers

All 7 Replies

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

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

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;

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)

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.

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.

commented: Completely nonsensical. -4

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"

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.