|
-
January 27th, 2011, 09:11 PM
#1
contrasting pointers from non-pointers
Hi All,
This is a general elementary level C question, but somehow i am stuckup at its logical understanding. hopefully i can get good know-how on it from the forum.
My question is that if we say that a pointer type variable is a variable whose address is known to us somehow. So we access that variable by using its address that is saved at some other location in the memory.
Now assuming that my above understanding is correct for a pointer type variable, then i want to know how would we access some variable which is just a simple int type or long type etc... and we dont know its addess in the memory?
Any help would be great.
-naim1
Last edited by naim1; January 27th, 2011 at 09:14 PM.
-
January 28th, 2011, 03:06 AM
#2
Re: contrasting pointers from non-pointers
You missed one level of indirection. A pointer is a variable which stores one address, it´s not the address itself. So using the pointer´s "value" means accessing a specific memory location.
Each variable, no matter what type, has its own address where it resides in memory.
- Guido
-
January 28th, 2011, 05:06 AM
#3
Re: contrasting pointers from non-pointers
Thanks for the reply. I think it makes sense now... little ilttle.
BTW, does a simple C compiler makes any address lookup table while compiling a program to keep track of the variables while execution , or some way other ...
-
January 28th, 2011, 08:50 AM
#4
Re: contrasting pointers from non-pointers
The compiler maintains a lookup table like that while compiling but that table is discarded when the compiler finishes. When the program executes it has the addresses hard-coded inline in the machine code.
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|